diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-07-01 10:01:06 +0200 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2013-07-02 20:05:44 +0200 |
commit | 17e5d614a8647d51b9795cb8bccf97ee33ca2d58 (patch) | |
tree | 43289d0d20b195f300ab5be6ac825511b8b16a0f /libavcodec/jpeg2000dec.c | |
parent | 7e201d575dc4385eb67314b0419d4d77185e65f4 (diff) | |
download | ffmpeg-17e5d614a8647d51b9795cb8bccf97ee33ca2d58.tar.gz |
jpeg2000: Check zero bit-plane validity
Prevent integer overflows.
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Diffstat (limited to 'libavcodec/jpeg2000dec.c')
-rw-r--r-- | libavcodec/jpeg2000dec.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 83efab8bc4..ffe97eb59b 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -652,10 +652,16 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, else if (incl < 0) return incl; - if (!cblk->npasses) - cblk->nonzerobits = expn[bandno] + numgbits - 1 - - tag_tree_decode(s, prec->zerobits + cblkno, - 100); + if (!cblk->npasses) { + int v = expn[bandno] + numgbits - 1 - + tag_tree_decode(s, prec->zerobits + cblkno, 100); + if (v < 0) { + av_log(s->avctx, AV_LOG_ERROR, + "nonzerobits %d invalid\n", v); + return AVERROR_INVALIDDATA; + } + cblk->nonzerobits = v; + } if ((newpasses = getnpasses(s)) < 0) return newpasses; if ((llen = getlblockinc(s)) < 0) |