aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vp3.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2017-05-01 18:46:27 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2017-05-20 03:41:33 +0200
commit7f5c9250de0e3a8a16cb9095833df22537dd03df (patch)
treea7f5823e6df644098868daf2bc85c84ed86169ba /libavcodec/vp3.c
parent37f5bfaa2b0ad1918fe86e9edb13b0a23ac2838b (diff)
downloadffmpeg-7f5c9250de0e3a8a16cb9095833df22537dd03df.tar.gz
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 2f00300b779e7b247c85db0d7daef448225105ff) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/vp3.c')
-rw-r--r--libavcodec/vp3.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index de78851084..fe58d097ae 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -1071,6 +1071,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);
@@ -1080,6 +1083,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]);
@@ -1102,6 +1107,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);