avcodec/jpeg2000dec: check sample sepration for validity
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 7 Aug 2013 13:02:38 +0000 (15:02 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 7 Aug 2013 13:09:35 +0000 (15:09 +0200)
Fixes division by 0
Fixes Ticket2841

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

index fb4e52b..1eb20ac 100644 (file)
@@ -273,6 +273,10 @@ static int get_siz(Jpeg2000DecoderContext *s)
         s->sgnd[i]   = !!(x & 0x80);
         s->cdx[i]    = bytestream2_get_byteu(&s->g);
         s->cdy[i]    = bytestream2_get_byteu(&s->g);
+        if (!s->cdx[i] || !s->cdy[i]) {
+            av_log(s->avctx, AV_LOG_ERROR, "Invalid sample seperation\n");
+            return AVERROR_INVALIDDATA;
+        }
         log2_chroma_wh |= s->cdy[i] >> 1 << i * 4 | s->cdx[i] >> 1 << i * 4 + 2;
     }