aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-05-14 14:29:43 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-12-02 19:41:48 +0100
commit386368fd918abdc2bfa6b09a82e1b6942bd7e01b (patch)
tree91100fe33831d3ea6909f04ac5fa8371ca65b354 /libavcodec
parent7e7f52deda5fc1a8d9e0060e38470a7ecd5d0dd1 (diff)
downloadffmpeg-386368fd918abdc2bfa6b09a82e1b6942bd7e01b.tar.gz
avcodec/mss4: Check input size against skip bits
Fixes: Timeout (17sec -> 20ms) Fixes: 14615/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MTS2_fuzzer-5093007763701760 Fixes: 14797/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MTS2_fuzzer-5651696119709696 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 0fef412dffb74fef3494f7fae0c138c32a444484) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mss4.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libavcodec/mss4.c b/libavcodec/mss4.c
index 9639fc820e..421658cd5b 100644
--- a/libavcodec/mss4.c
+++ b/libavcodec/mss4.c
@@ -552,6 +552,11 @@ static int mss4_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
"Empty frame found but it is not a skip frame.\n");
return AVERROR_INVALIDDATA;
}
+ mb_width = FFALIGN(width, 16) >> 4;
+ mb_height = FFALIGN(height, 16) >> 4;
+
+ if (frame_type != SKIP_FRAME && 8*buf_size < 8*HEADER_SIZE + mb_width*mb_height)
+ return AVERROR_INVALIDDATA;
if ((ret = ff_reget_buffer(avctx, c->pic)) < 0)
return ret;
@@ -574,9 +579,6 @@ static int mss4_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if ((ret = init_get_bits8(&gb, buf + HEADER_SIZE, buf_size - HEADER_SIZE)) < 0)
return ret;
-
- mb_width = FFALIGN(width, 16) >> 4;
- mb_height = FFALIGN(height, 16) >> 4;
dst[0] = c->pic->data[0];
dst[1] = c->pic->data[1];
dst[2] = c->pic->data[2];