summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2017-01-29 19:45:59 +0000
committerMark Thompson <sw@jkqxz.net>2017-01-30 23:03:52 +0000
commit708e84cda1bdbffb92847f3d6ccf6fbeb26d9948 (patch)
treec01bdf2b10d698863c6443d88da4deb8747d614b
parentca62236a89f47bd871eaf69d8d9e837c93c55a6c (diff)
mov: Avoid memcmp of uninitialised data
The string codec name need not be as long as the value we are comparing it to, so memcmp may make decisions derived from uninitialised data that valgrind then complains about (though the overall result of the function will always be the same). Use strncmp instead, which will stop at the first zero byte and therefore not encounter this issue.
-rw-r--r--libavformat/mov.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 37afe79df0..9afd0202ca 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1455,11 +1455,11 @@ static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb,
av_dict_set(&st->metadata, "encoder", codec_name, 0);
/* codec_tag YV12 triggers an UV swap in rawdec.c */
- if (!memcmp(codec_name, "Planar Y'CbCr 8-bit 4:2:0", 25))
+ if (!strncmp(codec_name, "Planar Y'CbCr 8-bit 4:2:0", 25))
st->codecpar->codec_tag = MKTAG('I', '4', '2', '0');
/* Flash Media Server uses tag H.263 with Sorenson Spark */
if (st->codecpar->codec_tag == MKTAG('H','2','6','3') &&
- !memcmp(codec_name, "Sorenson H263", 13))
+ !strncmp(codec_name, "Sorenson H263", 13))
st->codecpar->codec_id = AV_CODEC_ID_FLV1;
st->codecpar->bits_per_coded_sample = avio_rb16(pb); /* depth */