From 4ced30908fb7be270011dd6096809fe28b8a0e48 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 23 Jul 2013 04:12:04 +0200 Subject: [PATCH] avcodec/jpeg2000dec: make SOC finding code more robust Fixes file from Ticket860 Signed-off-by: Michael Niedermayer --- libavcodec/jpeg2000dec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 8c0e6ffd66..e67f098a6d 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -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;