avcodec/smc: Check input packet size
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 23 Feb 2018 02:40:02 +0000 (03:40 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 24 Feb 2018 03:50:55 +0000 (04:50 +0100)
Fixes: Timeout
Fixes: 6261/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMC_fuzzer-5811309653262336

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

index 79f9a75..3cb4834 100644 (file)
@@ -438,6 +438,10 @@ static int smc_decode_frame(AVCodecContext *avctx,
     int pal_size;
     const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
     int ret;
+    int total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4);
+
+    if (total_blocks / 1024 > avpkt->size)
+        return AVERROR_INVALIDDATA;
 
     bytestream2_init(&s->gb, buf, buf_size);