[MPlayer-dev-eng] [PATCH 6/7] stream ftp: Allocate command buffer on-heap

Reimar Döffinger Reimar.Doeffinger at gmx.de
Thu Nov 15 08:35:02 CET 2012



On 15 Nov 2012, at 03:42, Sergey <sergemp at mail.ru> wrote:

> On Mon, 12 Nov 2012 Reimar Döffinger wrote:
> 
>>> +    snprintf(p->cmd_buf,CMD_BUFSIZE - 1,"REST %"PRId64, (int64_t)newpos);
>> 
>> There should be no -1 for the size argument (same for all other
>> snprintfs).
> 
> Are you sure?
> 
> My man snprintf says:
>    The  functions  snprintf() and vsnprintf() write at most size
>    bytes (including the trailing null byte (’\0’)) to str.
> But it does not say that \0 is always stored there.

Read the POSIX or C99 specification.

> Also this page explicitly says that it may not be stored:
>  http://msdn.microsoft.com/en-us/library/2ts7cx93.aspx

Microsoft does not have a snprintf function at all, you are referring to _snprintf here.
Also subtracting 1 would still not help one bit with that one, since you would still miss the 0-termination.


More information about the MPlayer-dev-eng mailing list