mirror of https://git.ffmpeg.org/ffmpeg.git
avcodec/vp3: Check remaining bits in unpack_dct_coeffs()
Decreases the time spend decoding junk.
May fix: 1283/clusterfuzz-testcase-minimized-6221126759874560
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2f00300b77
)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
d9e4b19269
commit
737624e06c
|
@ -1068,6 +1068,9 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
|
|||
|
||||
s->dct_tokens[0][0] = s->dct_tokens_base;
|
||||
|
||||
if (get_bits_left(gb) < 16)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
/* fetch the DC table indexes */
|
||||
dc_y_table = get_bits(gb, 4);
|
||||
dc_c_table = get_bits(gb, 4);
|
||||
|
@ -1077,6 +1080,8 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
|
|||
0, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
if (get_bits_left(gb) < 8)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
/* reverse prediction of the Y-plane DC coefficients */
|
||||
reverse_dc_prediction(s, 0, s->fragment_width[0], s->fragment_height[0]);
|
||||
|
@ -1099,6 +1104,8 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
|
|||
s->fragment_width[1], s->fragment_height[1]);
|
||||
}
|
||||
|
||||
if (get_bits_left(gb) < 8)
|
||||
return AVERROR_INVALIDDATA;
|
||||
/* fetch the AC table indexes */
|
||||
ac_y_table = get_bits(gb, 4);
|
||||
ac_c_table = get_bits(gb, 4);
|
||||
|
|
Loading…
Reference in New Issue