diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2019-05-01 00:40:03 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2019-05-12 16:31:39 +0200 |
commit | e5ce10514918cec2ca25cf48e0dcc80d68e18656 (patch) | |
tree | a5cf094cdb8727b8d70df542b4bcb1ee11f37fb2 | |
parent | 1cc7e2630fecac0b91e28f402a02f7e268c9d156 (diff) | |
download | ffmpeg-e5ce10514918cec2ca25cf48e0dcc80d68e18656.tar.gz |
avcodec/wmv2dec: Check input bits vs. coded MBs
Fixes: Timeout (94sec ->8sec)
Fixes: 14387/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV2_fuzzer-5723546887651328
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/wmv2dec.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c index 124dfdb7e0..afa65478e3 100644 --- a/libavcodec/wmv2dec.c +++ b/libavcodec/wmv2dec.c @@ -33,6 +33,7 @@ static int parse_mb_skip(Wmv2Context *w) { int mb_x, mb_y; + int coded_mb_count = 0; MpegEncContext *const s = &w->s; uint32_t *const mb_type = s->current_picture_ptr->mb_type; @@ -83,6 +84,14 @@ static int parse_mb_skip(Wmv2Context *w) } break; } + + for (mb_y = 0; mb_y < s->mb_height; mb_y++) + for (mb_x = 0; mb_x < s->mb_width; mb_x++) + coded_mb_count += !IS_SKIP(mb_type[mb_y * s->mb_stride + mb_x]); + + if (coded_mb_count > get_bits_left(&s->gb)) + return AVERROR_INVALIDDATA; + return 0; } |