aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-06-16 15:27:39 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-06-16 15:27:39 +0200
commit3b8617429014301b26b587a5e537910746d3377a (patch)
treed94deea2fe7ace1b15940234386b594e3cb67c9a
parent3e17eec607307ca4340f5f97d7488285b89a3b97 (diff)
downloadffmpeg-3b8617429014301b26b587a5e537910746d3377a.tar.gz
avcodec/jpeg2000dec: move bpno check to a earlier place
This prevents additional integer overflows Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/jpeg2000dec.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index f821292769..9da66105a6 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -633,10 +633,16 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s,
else if (incl < 0)
return incl;
- if (!cblk->npasses)
- cblk->nonzerobits = expn[bandno] + numgbits - 1 -
+ 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)
@@ -913,10 +919,6 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,
ff_mqc_initdec(&t1->mqc, cblk->data);
while (passno--) {
- if (bpno < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "bpno invalid\n");
- return AVERROR(EINVAL);
- }
switch(pass_t) {
case 0:
decode_sigpass(t1, width, height, bpno + 1, bandpos,