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

Mark Thompson sw at jkqxz.net
Sun Dec 9 20:03:33 EET 2018


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 ? "," : ""'?)

Thanks,

- Mark


More information about the ffmpeg-devel mailing list