avcodec/diracdec: check that GetBitContext has not ended in codeblock()
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 13 Sep 2018 22:22:13 +0000 (00:22 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 27 Sep 2018 23:35:12 +0000 (01:35 +0200)
Fixes: Timeout (part 2 of 2)
Fixes: 9774/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5748957085958144

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/diracdec.c

index cbd7fd1..af561d1 100644 (file)
@@ -548,6 +548,8 @@ static inline int codeblock(DiracContext *s, SubBand *b,
         }
     } else {
         for (y = top; y < bottom; y++) {
+            if (get_bits_left(gb) < 1)
+                return AVERROR_INVALIDDATA;
             for (x = left; x < right; x++) {
                 int val = coeff_unpack_golomb(gb, qfactor, qoffset);
                 if (b->pshift) {