jpeg2000: Check component number in get_coc() and get_qcc()
Avoid overreads. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at> Signed-off-by: Nicolas Bertrand <nicoinattendu@gmail.com> Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
parent
17e5d614a8
commit
eae63e3c15
@ -362,6 +362,13 @@ static int get_coc(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,
|
||||
|
||||
compno = bytestream2_get_byteu(&s->g);
|
||||
|
||||
if (compno >= s->ncomponents) {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"Invalid compno %d. There are %d components in the image.\n",
|
||||
compno, s->ncomponents);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
c += compno;
|
||||
c->csty = bytestream2_get_byteu(&s->g);
|
||||
get_cox(s, c);
|
||||
@ -441,6 +448,14 @@ static int get_qcc(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q,
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
compno = bytestream2_get_byteu(&s->g);
|
||||
|
||||
if (compno >= s->ncomponents) {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"Invalid compno %d. There are %d components in the image.\n",
|
||||
compno, s->ncomponents);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
properties[compno] |= HAD_QCC;
|
||||
return get_qcx(s, n - 1, q + compno);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user