Merge commit 'f1476459b7013d306eb911573f1dc81e74ccd082' into release/1.1
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 4 Feb 2014 04:43:42 +0000 (05:43 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 4 Feb 2014 04:43:42 +0000 (05:43 +0100)
* commit 'f1476459b7013d306eb911573f1dc81e74ccd082':
  vmnc: K&R formatting cosmetics
  flashsv: Check diff_start diff_height values
  dsputil/pngdsp: fix signed/unsigned type in end comparison

Conflicts:
libavcodec/dsputil.c
libavcodec/flashsv.c
libavcodec/vmnc.c

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

Simple merge
Simple merge
@@@ -276,12 -300,8 +300,13 @@@ static int decode_hextile(VmncContext *
                      }
                      xy = *src++;
                      wh = *src++;
-                     paint_rect(dst2, xy >> 4, xy & 0xF, (wh>>4)+1, (wh & 0xF)+1, fg, bpp, stride);
 +                    if (   (xy >> 4) + (wh >> 4) + 1 > w - i
 +                        || (xy & 0xF) + (wh & 0xF)+1 > h - j) {
 +                        av_log(c->avctx, AV_LOG_ERROR, "Rectangle outside picture\n");
 +                        return AVERROR_INVALIDDATA;
 +                    }
+                     paint_rect(dst2, xy >> 4, xy & 0xF, (wh >> 4) + 1,
+                                (wh & 0xF) + 1, fg, bpp, stride);
                  }
              }
          }
@@@ -336,27 -359,27 +364,35 @@@ static int decode_frame(AVCodecContext 
          }
      }
      src += 2;
-     chunks = AV_RB16(src); src += 2;
+     chunks = AV_RB16(src);
+     src += 2;
 -    while (chunks--) {
 +    while(chunks--) {
 +        if(buf_size - (src - buf) < 12) {
 +            av_log(avctx, AV_LOG_ERROR, "Premature end of data!\n");
 +            return -1;
 +        }
-         dx = AV_RB16(src); src += 2;
-         dy = AV_RB16(src); src += 2;
-         w  = AV_RB16(src); src += 2;
-         h  = AV_RB16(src); src += 2;
-         enc = AV_RB32(src); src += 4;
+         dx  = AV_RB16(src);
+         src += 2;
+         dy  = AV_RB16(src);
+         src += 2;
+         w   = AV_RB16(src);
+         src += 2;
+         h   = AV_RB16(src);
+         src += 2;
+         enc = AV_RB32(src);
+         src += 4;
          outptr = c->pic.data[0] + dx * c->bpp2 + dy * c->pic.linesize[0];
          size_left = buf_size - (src - buf);
-         switch(enc) {
+         switch (enc) {
          case MAGIC_WMVd: // cursor
 -            if (size_left < 2 + w * h * c->bpp2 * 2) {
 +            if (w*(int64_t)h*c->bpp2 > INT_MAX/2 - 2) {
 +                av_log(avctx, AV_LOG_ERROR, "dimensions too large\n");
 +                return AVERROR_INVALIDDATA;
 +            }
 +            if(size_left < 2 + w * h * c->bpp2 * 2) {
-                 av_log(avctx, AV_LOG_ERROR, "Premature end of data! (need %i got %i)\n", 2 + w * h * c->bpp2 * 2, size_left);
+                 av_log(avctx, AV_LOG_ERROR,
+                        "Premature end of data! (need %i got %i)\n",
+                        2 + w * h * c->bpp2 * 2, size_left);
                  return -1;
              }
              src += 2;
@@@ -478,16 -512,13 +525,15 @@@ static av_cold int decode_init(AVCodecC
  {
      VmncContext * const c = avctx->priv_data;
  
-     c->avctx = avctx;
-     c->width = avctx->width;
+     c->avctx  = avctx;
+     c->width  = avctx->width;
      c->height = avctx->height;
+     c->bpp    = avctx->bits_per_coded_sample;
+     c->bpp2   = c->bpp / 8;
  
-     c->bpp = avctx->bits_per_coded_sample;
-     c->bpp2 = c->bpp/8;
 +    avcodec_get_frame_defaults(&c->pic);
 +
-     switch(c->bpp){
+     switch (c->bpp) {
      case 8:
          avctx->pix_fmt = AV_PIX_FMT_PAL8;
          break;