Browse code

avcodec/aic: Check remaining bits in aic_decode_coeffs()

Fixes: Timeout (78 seconds -> 2 seconds)
Fixes: 13186/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AIC_fuzzer-5639516533030912

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 951bb7632fe6e3bb1a9c3b47610705871e471f34)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

Michael Niedermayer authored on 2019/02/25 21:26:25
Showing 1 changed files
... ...
@@ -208,6 +208,9 @@ static int aic_decode_coeffs(GetBitContext *gb, int16_t *dst,
208 208
     int mb, idx;
209 209
     unsigned val;
210 210
 
211
+    if (get_bits_left(gb) < 5)
212
+        return AVERROR_INVALIDDATA;
213
+
211 214
     has_skips  = get_bits1(gb);
212 215
     coeff_type = get_bits1(gb);
213 216
     coeff_bits = get_bits(gb, 3);