If lowres value greater than number of decomposition level: raise an
error.
---
The check of lowres value also avoids a segmentation fault if
lowres > c->nreslevels
libavcodec/jpeg2000dec.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index f789d19..6b5925d 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -251,12 +251,15 @@ static int get_cox(Jpeg2000DecoderContext *s,
Jpeg2000CodingStyle *c)
if (s->buf_end - s->buf < 5)
return AVERROR(EINVAL);
- c->nreslevels = bytestream_get_byte(&s->buf) + 1; // num of resolution
levels - 1
+ c->nreslevels = bytestream_get_byte(&s->buf) + 1; // num of resolution
levels
/* compute number of resolution levels to decode */
- if (c->nreslevels < s->reduction_factor)
- c->nreslevels2decode = 1;
- else
+ if (c->nreslevels <= s->reduction_factor) {
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Cannot set lowres to %d, maximum lowres for this file is %d.\n",
+ s->reduction_factor, c->nreslevels - 1);
+ return EINVAL;
+ } else
c->nreslevels2decode = c->nreslevels - s->reduction_factor;
c->log2_cblk_width = bytestream_get_byte(&s->buf) + 2; // cblk width
--
1.7.9.5
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel