avcodec/dfa: Check the chunk header is not truncated
authorMichael Niedermayer <michael@niedermayer.cc>
Sun, 10 Mar 2019 22:45:19 +0000 (23:45 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 17 Mar 2019 10:35:00 +0000 (11:35 +0100)
Fixes: Timeout (11sec -> 3sec)
Fixes: 13218/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DFA_fuzzer-5661074316066816

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/dfa.c

index 970175f..c6106b9 100644 (file)
@@ -355,6 +355,8 @@ static int dfa_decode_frame(AVCodecContext *avctx,
 
     bytestream2_init(&gb, avpkt->data, avpkt->size);
     while (bytestream2_get_bytes_left(&gb) > 0) {
+        if (bytestream2_get_bytes_left(&gb) < 12)
+            return AVERROR_INVALIDDATA;
         bytestream2_skip(&gb, 4);
         chunk_size = bytestream2_get_le32(&gb);
         chunk_type = bytestream2_get_le32(&gb);