jpeg2000dec: Check compno in get_coc()
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 13 Jun 2013 23:54:30 +0000 (01:54 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 13 Jun 2013 23:55:43 +0000 (01:55 +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 87a1d58..b856db4 100644 (file)
@@ -354,6 +354,11 @@ static int get_coc(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,
 
     compno = bytestream2_get_byteu(&s->g);
 
+    if (compno >= s->ncomponents) {
+        av_log(s->avctx, AV_LOG_ERROR, "Invalid compno %d\n", compno);
+        return AVERROR_INVALIDDATA;
+    }
+
     c      += compno;
     c->csty = bytestream2_get_byteu(&s->g);