diff mbox

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

Message ID CAB0OVGqPKQ3kA6ZUdVmr2dTV0DXOqx5g5u9a96z9Vc5zkdGO5g@mail.gmail.com
State Superseded
Headers show

Commit Message

Carl Eugen Hoyos Dec. 6, 2018, 10:26 p.m. UTC
Hi!

Attached patch silences a new gcc warning, alternative would be to
disable the warning.

Please comment, Carl Eugen

Comments

Mark Thompson Dec. 9, 2018, 6:03 p.m. UTC | #1
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@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
diff mbox

Patch

From dd49cddc6fad136222d4a168301059d55fea4a4c Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@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