aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-02-23 03:40:02 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2018-06-18 01:16:03 +0200
commit30a718c38b62250ef191c8ce040c6c6666ae928c (patch)
tree94043a84aeaebde8d4043736d1d0b6cc343bf5a1
parent411310659591107409d1211e00a005c2cef2d08a (diff)
downloadffmpeg-30a718c38b62250ef191c8ce040c6c6666ae928c.tar.gz
avcodec/smc: Check input packet size
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> (cherry picked from commit 0293663483ab5dbfff23602a62800d84e021b33c) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/smc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libavcodec/smc.c b/libavcodec/smc.c
index 79f9a757a0..3cb4834737 100644
--- a/libavcodec/smc.c
+++ b/libavcodec/smc.c
@@ -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);