summaryrefslogtreecommitdiff
path: root/libavcodec/jpeg2000dec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-05-21 21:36:32 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-05-21 21:44:34 +0200
commit069ede29811685ed7b2cf958471eee455aab2077 (patch)
tree5e57c193affc793ae77b7c38ebae339327e7ccc9 /libavcodec/jpeg2000dec.c
parent78c7bff04ac5180b47e739edbe015ff6b11bf0b9 (diff)
jpeg2000dec: Check ncomponents and tile dimensions
Fixes various problems Code ported from j2kdec Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/jpeg2000dec.c')
-rw-r--r--libavcodec/jpeg2000dec.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index f7e6b6e8ab..60489be0a3 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -176,6 +176,13 @@ static int get_siz(Jpeg2000DecoderContext *s)
s->tile_offset_y = bytestream_get_be32(&s->buf); // YT0Siz
s->ncomponents = bytestream_get_be16(&s->buf); // CSiz
+ if(s->ncomponents <= 0 || s->ncomponents > 4) {
+ av_log(s->avctx, AV_LOG_ERROR, "unsupported/invalid ncomponents: %d\n", s->ncomponents);
+ return AVERROR(EINVAL);
+ }
+ if(s->tile_width<=0 || s->tile_height<=0)
+ return AVERROR(EINVAL);
+
if (s->buf_end - s->buf < 2 * s->ncomponents)
return AVERROR(EINVAL);