diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-06-06 10:50:33 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-06-06 10:51:07 +0200 |
commit | b26bcd08e670b90740f7253f21adddafb9d8c478 (patch) | |
tree | 059e43e88a90223b2a0c783ed100f122fb6432ef /libavcodec | |
parent | c51654fbc023f22feabee68a858a1a33e12ed9f6 (diff) | |
download | ffmpeg-b26bcd08e670b90740f7253f21adddafb9d8c478.tar.gz |
jpeg2000dec: Check that theres a SOT before SOD
Fixes out of array access
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/jpeg2000dec.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 49680362f0..fdc0a93f54 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -1208,9 +1208,16 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s) oldpos = bytestream2_tell(&s->g); if (marker == JPEG2000_SOD) { - Jpeg2000Tile *tile = s->tile + s->curtileno; - Jpeg2000TilePart *tp = tile->tile_part + tile->tp_idx; + Jpeg2000Tile *tile; + Jpeg2000TilePart *tp; + if (s->curtileno < 0) { + av_log(s->avctx, AV_LOG_ERROR, "Missing SOT\n"); + return AVERROR_INVALIDDATA; + } + + tile = s->tile + s->curtileno; + tp = tile->tile_part + tile->tp_idx; bytestream2_init(&tp->tpg, s->g.buffer, tp->tp_end - s->g.buffer); bytestream2_skip(&s->g, tp->tp_end - s->g.buffer); |