avcodec/jpeg2000dec: Add some additional checking on lengthinc
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 11 Jun 2015 23:13:55 +0000 (01:13 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 11 Jun 2015 23:13:55 +0000 (01:13 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/jpeg2000dec.c

index 6f4bd19..aa6d8ec 100644 (file)
@@ -807,6 +807,12 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s,
                 return newpasses;
             if ((llen = getlblockinc(s)) < 0)
                 return llen;
+            if (cblk->lblock + llen + av_log2(newpasses) > 16) {
+                avpriv_request_sample(s->avctx,
+                                      "Block with length beyond 16 bits\n");
+                return AVERROR_PATCHWELCOME;
+            }
+
             cblk->lblock += llen;
             if ((ret = get_bits(s, av_log2(newpasses) + cblk->lblock)) < 0)
                 return ret;