diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-11-24 03:50:20 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-12-24 01:05:47 +0100 |
commit | bd9dcb411d2e036193ddc6a829842ae9e9a05a4b (patch) | |
tree | d391a70b9a10194dd121c190e38cbcf6eb9342a8 | |
parent | ae81a0e32de6fa53a2670fe0dbb5d2a252030281 (diff) | |
download | ffmpeg-bd9dcb411d2e036193ddc6a829842ae9e9a05a4b.tar.gz |
avcodec/jpeg2000dec: Check precno before using it in JPEG2000_PGOD_CPRL
Fixes out of array reads
Fixes: asan_heap-oob_f0de57_6823_mjp2.mov
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 3d5a5e86be2a65e33c34ab3ad7923f54e8e49c1d)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/jpeg2000dec.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 66abd59948..d70413a0da 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -884,6 +884,10 @@ static int jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile prcx = ff_jpeg2000_ceildivpow2(x, reducedresno) >> rlevel->log2_prec_width; prcy = ff_jpeg2000_ceildivpow2(y, reducedresno) >> rlevel->log2_prec_height; precno = prcx + rlevel->num_precincts_x * prcy; + + if (prcx >= rlevel->num_precincts_x || prcy >= rlevel->num_precincts_y) + return AVERROR_PATCHWELCOME; + for (layno = 0; layno < tile->codsty[0].nlayers; layno++) { if ((ret = jpeg2000_decode_packet(s, codsty, rlevel, precno, layno, |