diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-12-19 20:48:51 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-12-19 21:46:47 +0100 |
commit | 8fe06e7ae8ffde7d4b5eef04a20c9faa45f61439 (patch) | |
tree | 10cfdc79321bbfb9f7ecd18f1334631563ef3c22 /libavformat/nistspheredec.c | |
parent | b3f44eafa5a8748f777d0935d6e5562a604d8770 (diff) | |
download | ffmpeg-8fe06e7ae8ffde7d4b5eef04a20c9faa45f61439.tar.gz |
avformat/nistspheredec: check sscanf() success before using the result
Fixes use of uninitialized memory
Fixes: msan_uninit-mem_7f935c3c6c1a_7413_nist_pcms8.nist
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/nistspheredec.c')
-rw-r--r-- | libavformat/nistspheredec.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libavformat/nistspheredec.c b/libavformat/nistspheredec.c index c09df9ccc1..76f65ec6e0 100644 --- a/libavformat/nistspheredec.c +++ b/libavformat/nistspheredec.c @@ -108,8 +108,11 @@ static int nist_read_header(AVFormatContext *s) sscanf(buffer, "%*s %*s %"SCNd32, &st->codec->bits_per_coded_sample); } else { char key[32], value[32]; - sscanf(buffer, "%31s %*s %31s", key, value); - av_dict_set(&s->metadata, key, value, AV_DICT_APPEND); + if (sscanf(buffer, "%31s %*s %31s", key, value) == 3) { + av_dict_set(&s->metadata, key, value, AV_DICT_APPEND); + } else { + av_log(s, AV_LOG_ERROR, "Failed to parse '%s' as metadata\n", buffer); + } } } |