aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vc1dec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-12-08 19:37:46 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2020-04-23 21:29:01 +0200
commit6be091ce221081b1a3275e24174e9145c8d98ea6 (patch)
treef5ad8b859e55f572bf8ae1284abda7d00018956b /libavcodec/vc1dec.c
parent92503fd8a940d56b5b327b914a7f418a67254bec (diff)
downloadffmpeg-6be091ce221081b1a3275e24174e9145c8d98ea6.tar.gz
avcodec/vc1dec: Limit bits by the actual bitstream size
Fixes: Timeout (350 ->19sec) Fixes: 19249/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-6566896438870016 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 c56a52a82c0a4039e606e82b948a8abfe417f35f) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/vc1dec.c')
-rw-r--r--libavcodec/vc1dec.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 3a4936c831..77fafbb2c3 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -971,7 +971,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
ff_mpeg_er_frame_start(s);
- v->bits = buf_size * 8;
+ v->bits = FFMIN(buf_size * 8, s->gb.size_in_bits);
v->end_mb_x = s->mb_width;
if (v->field_mode) {
s->current_picture.f->linesize[0] <<= 1;
@@ -1043,8 +1043,10 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
continue;
}
ff_vc1_decode_blocks(v);
- if (i != n_slices)
+ if (i != n_slices) {
s->gb = slices[i].gb;
+ v->bits = FFMIN(buf_size * 8, s->gb.size_in_bits);
+ }
}
if (v->field_mode) {
v->second_field = 0;