avformat/mvdec: Fix DoS due to lack of eof check
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 24 Aug 2017 23:15:30 +0000 (01:15 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 27 Aug 2017 23:43:28 +0000 (01:43 +0200)
Fixes: loop.mv

Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4f05e2e2dc1a89f38cd9f0960a6561083d714f1e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mvdec.c

index 7aa6452..e3feda6 100644 (file)
@@ -338,6 +338,8 @@ static int mv_read_header(AVFormatContext *avctx)
             uint32_t pos   = avio_rb32(pb);
             uint32_t asize = avio_rb32(pb);
             uint32_t vsize = avio_rb32(pb);
+            if (avio_feof(pb))
+                return AVERROR_INVALIDDATA;
             avio_skip(pb, 8);
             av_add_index_entry(ast, pos, timestamp, asize, 0, AVINDEX_KEYFRAME);
             av_add_index_entry(vst, pos + asize, i, vsize, 0, AVINDEX_KEYFRAME);