[FFmpeg-devel] [PATCH 2/2] avcodec/prosumer: Check decoded size

Michael Niedermayer michael at niedermayer.cc
Wed Mar 20 02:02:37 EET 2019


Fixes: Timeout (longer than i had patience for -> 2sec)
Fixes: 13205/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PROSUMER_fuzzer-5105644481282048

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/prosumer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/prosumer.c b/libavcodec/prosumer.c
index ce3cbdbb73..f064f7bad7 100644
--- a/libavcodec/prosumer.c
+++ b/libavcodec/prosumer.c
@@ -159,6 +159,8 @@ static int decode_frame(AVCodecContext *avctx, void *data,
     ret = decompress(&s->gb, AV_RL32(avpkt->data + 28) >> 1, &s->pb, s->lut);
     if (ret < 0)
         return ret;
+    if (bytestream2_get_bytes_left_p(&s->pb) > s->size * (int64_t)avctx->discard_damaged_percentage / 100)
+        return AVERROR_INVALIDDATA;
     vertical_predict((uint32_t *)s->decbuffer, 0, (uint32_t *)s->initial_line, s->stride, 1);
     vertical_predict((uint32_t *)s->decbuffer, s->stride, (uint32_t *)s->decbuffer, s->stride, avctx->height - 1);
 
-- 
2.21.0



More information about the ffmpeg-devel mailing list