diff options
author | Paul B Mahol <onemda@gmail.com> | 2012-06-15 11:46:12 +0000 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2012-06-15 12:02:37 +0000 |
commit | 29e9f83192fd366f83a314adfb7892381c2280f5 (patch) | |
tree | 410a1ae78c511adc9c4c3d4ed9be90d07a3f0c12 | |
parent | dd2086140c00c25ee2889dbee607ada268d6cbf6 (diff) | |
download | ffmpeg-29e9f83192fd366f83a314adfb7892381c2280f5.tar.gz |
j2kdec: check colorspace ncomponents
This prevents out of array read.
Signed-off-by: Paul B Mahol <onemda@gmail.com>
-rw-r--r-- | libavcodec/j2kdec.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libavcodec/j2kdec.c b/libavcodec/j2kdec.c index 9c2022e42d..59c2188bb7 100644 --- a/libavcodec/j2kdec.c +++ b/libavcodec/j2kdec.c @@ -217,6 +217,10 @@ static int get_siz(J2kDecoderContext *s) s->tile_offset_y = bytestream2_get_be32u(&s->g); // YT0Siz s->ncomponents = bytestream2_get_be16u(&s->g); // 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); |