]> git.sesse.net Git - ffmpeg/commitdiff
avformat/aadec: Replace strncpy by av_strlcpy
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 2 Mar 2021 09:00:18 +0000 (10:00 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 5 Mar 2021 08:16:00 +0000 (09:16 +0100)
While this usage of strncpy is correct, said function nevertheless has
the disadvantage of not automatically ensuring that the destination
string is zero-terminated. So av_strlcpy should be preferred.
This also removes a -Wstringop-truncation warning from GCC (it doesn't
matter whether the buffer is truncated, as long as it can fit all
the names of the supported codecs).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavformat/aadec.c

index b1e93ea072c02f1b2cb6655b007aededb05ebfe2..e88cdb89df7708fe774c3cb0155fd18dea6f84a4 100644 (file)
@@ -114,7 +114,7 @@ static int aa_read_header(AVFormatContext *s)
         avio_get_str(pb, nval, val, sizeof(val));
         if (!strcmp(key, "codec")) {
             av_log(s, AV_LOG_DEBUG, "Codec is <%s>\n", val);
-            strncpy(codec_name, val, sizeof(codec_name) - 1);
+            av_strlcpy(codec_name, val, sizeof(codec_name));
         } else if (!strcmp(key, "HeaderSeed")) {
             av_log(s, AV_LOG_DEBUG, "HeaderSeed is <%s>\n", val);
             header_seed = atoi(val);