avcodec/huffyuvdec: Check input buffer size
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 31 Jan 2018 18:20:10 +0000 (19:20 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 9 Feb 2018 02:01:30 +0000 (03:01 +0100)
Fixes: Timeout
Fixes: 5487/clusterfuzz-testcase-4696837035393024

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/huffyuvdec.c

index 979c4b9..66357bf 100644 (file)
@@ -919,6 +919,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
     AVFrame *const p = data;
     int table_size = 0, ret;
 
+    if (buf_size < (width * height + 7)/8)
+        return AVERROR_INVALIDDATA;
+
     av_fast_padded_malloc(&s->bitstream_buffer,
                    &s->bitstream_buffer_size,
                    buf_size);