[rtmpdump] [PATCH] Limit length of filename

Howard Chu hyc at highlandsun.com
Mon May 21 11:59:34 CEST 2012


Steven Penny wrote:
> In some cases YouTube RTMPE streams are generating filenames over 300 characters
> in length. Worst I saw was 336. Certain operating systems do not support names
> of this length. From my tests I set the limit to the max allowed.

Try not to use naked magic numbers like this. Use a #define and a comment 
explaining what the value is, why it was chosen, etc...

I don't believe simple truncation like this is a good policy. You'll run into 
filename collisions.

rtmpsrv is not really meant to be actively used; it was just a debugging tool 
for me to figure out what parameters an RTMP client/server was expecting. It 
was also meant to serve as example code for other people to write full blown 
servers. Minor details like filename lengths aren't really part of the mission 
of this code. I generally ignore patches/enhancements for rtmpsrv.

> ---
>   rtmpsrv.c |    6 ++++++
>   1 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/rtmpsrv.c b/rtmpsrv.c
> index 9aa62f3..16ac4c1 100644
> --- a/rtmpsrv.c
> +++ b/rtmpsrv.c
> @@ -711,6 +711,12 @@ ServeInvoke(STREAMING_SERVER *server, RTMP * r, RTMPPacket *packet, unsigned int
>   	    if (*p == ':')
>   	      *p = '_';
>
> +	  /* Limit length of filename */
> +	  if (av.av_len > 223)
> +	    {
> +	      av.av_len = 223;
> +	    }
> +
>   	  /* Add extension if none present */
>   	  if (file[av.av_len - 4] != '.')
>   	    {
>


More information about the rtmpdump mailing list