avcodec/jpeg2000dec: make SOC finding code more robust
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 23 Jul 2013 02:12:04 +0000 (04:12 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 4 Sep 2013 23:39:20 +0000 (01:39 +0200)
Fixes file from Ticket860

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

index 8c0e6ff..e67f098 100644 (file)
@@ -1615,6 +1615,9 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data,
         bytestream2_seek(&s->g, 0, SEEK_SET);
     }
 
+    while (bytestream2_get_bytes_left(&s->g) >= 3 && bytestream2_peek_be16(&s->g) != JPEG2000_SOC)
+        bytestream2_skip(&s->g, 1);
+
     if (bytestream2_get_be16u(&s->g) != JPEG2000_SOC) {
         av_log(avctx, AV_LOG_ERROR, "SOC marker not present\n");
         ret = AVERROR_INVALIDDATA;