mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-11-27 13:10:37 +00:00
jpeg2000: Check that there is a SOT before SOD
Avoid overreads. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at> Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
parent
2c3901b2c3
commit
b564784a20
@ -1236,6 +1236,22 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
|
||||
marker = bytestream2_get_be16u(&s->g);
|
||||
oldpos = bytestream2_tell(&s->g);
|
||||
|
||||
if (marker == JPEG2000_SOD) {
|
||||
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);
|
||||
|
||||
continue;
|
||||
}
|
||||
if (marker == JPEG2000_EOC)
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user