j2kdec: Check curtileno for validity
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 24 Dec 2011 04:06:20 +0000 (05:06 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 12 Jan 2012 20:54:42 +0000 (21:54 +0100)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 3eedf9f716733b3b4c5205726d2c1ca52b3d3d78)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/j2kdec.c

index 96b4f64..3b94497 100644 (file)
@@ -421,6 +421,10 @@ static uint8_t get_sot(J2kDecoderContext *s)
         return AVERROR(EINVAL);
 
     s->curtileno = bytestream_get_be16(&s->buf); ///< Isot
+    if((unsigned)s->curtileno >= s->numXtiles * s->numYtiles){
+        s->curtileno=0;
+        return AVERROR(EINVAL);
+    }
 
     s->buf += 4; ///< Psot (ignored)