mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-04 06:08:26 +02:00
avcodec/jpeg2000dec: move bpno check to a earlier place
This prevents additional integer overflows Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
3e17eec607
commit
3b86174290
@ -633,10 +633,16 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s,
|
|||||||
else if (incl < 0)
|
else if (incl < 0)
|
||||||
return incl;
|
return incl;
|
||||||
|
|
||||||
if (!cblk->npasses)
|
if (!cblk->npasses) {
|
||||||
cblk->nonzerobits = expn[bandno] + numgbits - 1 -
|
int v = expn[bandno] + numgbits - 1 -
|
||||||
tag_tree_decode(s, prec->zerobits + cblkno,
|
tag_tree_decode(s, prec->zerobits + cblkno,
|
||||||
100);
|
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)
|
if ((newpasses = getnpasses(s)) < 0)
|
||||||
return newpasses;
|
return newpasses;
|
||||||
if ((llen = getlblockinc(s)) < 0)
|
if ((llen = getlblockinc(s)) < 0)
|
||||||
@ -913,10 +919,6 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,
|
|||||||
ff_mqc_initdec(&t1->mqc, cblk->data);
|
ff_mqc_initdec(&t1->mqc, cblk->data);
|
||||||
|
|
||||||
while (passno--) {
|
while (passno--) {
|
||||||
if (bpno < 0) {
|
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "bpno invalid\n");
|
|
||||||
return AVERROR(EINVAL);
|
|
||||||
}
|
|
||||||
switch(pass_t) {
|
switch(pass_t) {
|
||||||
case 0:
|
case 0:
|
||||||
decode_sigpass(t1, width, height, bpno + 1, bandpos,
|
decode_sigpass(t1, width, height, bpno + 1, bandpos,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user