aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/jpeg2000dec.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2013-07-01 10:00:58 +0200
committerLuca Barbato <lu_zero@gentoo.org>2013-07-02 20:05:43 +0200
commit5650e331a733711b809bc27f968500f0f5530126 (patch)
tree519c7cba29e59ca7f6ec449a01c07009478b5284 /libavcodec/jpeg2000dec.c
parent8ad3267ce3a1522a181946288049cc848cc9e351 (diff)
downloadffmpeg-5650e331a733711b809bc27f968500f0f5530126.tar.gz
jpeg2000: Validate resolution levels
There are 32 maximum decomposition levels, thus 33 resolution levels. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Diffstat (limited to 'libavcodec/jpeg2000dec.c')
-rw-r--r--libavcodec/jpeg2000dec.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 8c49ea9307..e29f73162b 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -251,7 +251,12 @@ 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
+ /* nreslevels = number of resolution levels
+ = number of decomposition level +1 */
+ c->nreslevels = bytestream_get_byte(&s->buf) + 1;
+
+ if (c->nreslevels > JPEG2000_MAX_RESLEVELS)
+ return AVERROR_INVALIDDATA;
/* compute number of resolution levels to decode */
if (c->nreslevels < s->reduction_factor)