Commit 17e5d614 authored by Michael Niedermayer's avatar Michael Niedermayer Committed by Luca Barbato

jpeg2000: Check zero bit-plane validity

Prevent integer overflows.
Signed-off-by: 's avatarLuca Barbato <lu_zero@gentoo.org>
parent 7e201d57
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment