[FFmpeg-devel] [PATCH]lavf/matroskadec: Do not use strncat() to limit copying a one-char constant

Carl Eugen Hoyos ceffmpeg at gmail.com
Mon Dec 10 02:57:34 EET 2018


2018-12-09 19:03 GMT+01:00, Mark Thompson <sw at jkqxz.net>:
> On 06/12/2018 22:26, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> Attached patch silences a new gcc warning, alternative would be to
>> disable the warning.
>>
>> Please comment, Carl Eugen
>>
>>
>> From dd49cddc6fad136222d4a168301059d55fea4a4c Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos <ceffmpeg at gmail.com>
>> Date: Thu, 6 Dec 2018 23:23:12 +0100
>> Subject: [PATCH] lavf/matroskadec: Do not use strncat() to limit copying a
>>  one-char constant.
>>
>> Silences a warning:
>> libavformat/matroskadec.c: In function 'webm_dash_manifest_cues':
>> libavformat/matroskadec.c:3947:13: warning: 'strncat' specified bound 1
>> equals source length [-Wstringop-overflow=]
>>              strncat(buf, ",", 1);
>>              ^~~~~~~~~~~~~~~~~~~~
>> ---
>>  libavformat/matroskadec.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
>> index 2daa1db..df820b4 100644
>> --- a/libavformat/matroskadec.c
>> +++ b/libavformat/matroskadec.c
>> @@ -3944,7 +3944,7 @@ static int webm_dash_manifest_cues(AVFormatContext
>> *s, int64_t init_range)
>>          }
>>          end += ret;
>>          if (i != s->streams[0]->nb_index_entries - 1) {
>> -            strncat(buf, ",", 1);
>> +            strcat(buf, ",");
>>              end++;
>>          }
>>      }
>> --
>> 1.7.10.4
>>
>
> LGTM.
>
> (Optional: perhaps nicer to remove that code fragment with the str(n?)cat
> completely by including the comma in the snprintf above, as '"%s", i !=
> s->streams[0]->nb_index_entries - 1 ? "," : ""'?)

New patch attached.

Please review, Carl Eugen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lavf-matroskadec-Do-not-use-strncat-to-limit-copying.patch
Type: text/x-patch
Size: 1805 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20181210/324a8a8f/attachment.bin>


More information about the ffmpeg-devel mailing list