Merge commit '5650e331a733711b809bc27f968500f0f5530126'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 3 Jul 2013 09:20:39 +0000 (11:20 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 3 Jul 2013 09:20:39 +0000 (11:20 +0200)
* commit '5650e331a733711b809bc27f968500f0f5530126':
  jpeg2000: Validate resolution levels

Conflicts:
libavcodec/jpeg2000dec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/jpeg2000dec.c

@@@ -264,13 -249,14 +264,15 @@@ static int get_cox(Jpeg2000DecoderConte
  {
      uint8_t byte;
  
 -    if (s->buf_end - s->buf < 5)
 +    if (bytestream2_get_bytes_left(&s->g) < 5)
          return AVERROR(EINVAL);
-     c->nreslevels = bytestream2_get_byteu(&s->g) + 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)
++    c->nreslevels = bytestream2_get_byteu(&s->g) + 1;
 +    if (c->nreslevels >= JPEG2000_MAX_RESLEVELS) {
 +        av_log(s->avctx, AV_LOG_ERROR, "nreslevels %d is invalid\n", c->nreslevels);
          return AVERROR_INVALIDDATA;
 +    }
  
      /* compute number of resolution levels to decode */
      if (c->nreslevels < s->reduction_factor)