get_qcc: Check compno
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 6 Jun 2013 00:19:24 +0000 (02:19 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 6 Jun 2013 00:26:22 +0000 (02:26 +0200)
Fixes out of array accesses

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/jpeg2000dec.c

index e8e95a1..c4b63ef 100644 (file)
@@ -425,6 +425,11 @@ static int get_qcc(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q,
         return AVERROR(EINVAL);
 
     compno              = bytestream2_get_byteu(&s->g);
+    if (compno >= s->ncomponents) {
+        av_log(s->avctx, AV_LOG_ERROR, "Invalid compno\n");
+        return AVERROR_INVALIDDATA;
+    }
+
     properties[compno] |= HAD_QCC;
     return get_qcx(s, n - 1, q + compno);
 }