Merge commit '77eb3d9a60a9c2bb6d87c960ac186af242bbcc9e' into release/2.4
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 8 Mar 2015 23:43:06 +0000 (00:43 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 8 Mar 2015 23:43:26 +0000 (00:43 +0100)
* commit '77eb3d9a60a9c2bb6d87c960ac186af242bbcc9e':
  tiff: Check that there is no aliasing in pixel format selection

Conflicts:
libavcodec/tiff.c

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

@@@ -650,23 -244,21 +650,31 @@@ static int tiff_unpack_strip(TiffContex
      return 0;
  }
  
 -static int init_image(TiffContext *s, AVFrame *frame)
 +static int init_image(TiffContext *s, ThreadFrame *frame)
  {
      int ret;
 +    int create_gray_palette = 0;
  
 -    switch (s->bpp * 10 + s->bppcount) {
+     // make sure there is no aliasing in the following switch
+     if (s->bpp >= 100 || s->bppcount >= 10) {
+         av_log(s->avctx, AV_LOG_ERROR,
+                "Unsupported image parameters: bpp=%d, bppcount=%d\n",
+                s->bpp, s->bppcount);
+         return AVERROR_INVALIDDATA;
+     }
 +    switch (s->planar * 1000 + s->bpp * 10 + s->bppcount) {
      case 11:
 -        s->avctx->pix_fmt = AV_PIX_FMT_MONOBLACK;
 +        if (!s->palette_is_set) {
 +            s->avctx->pix_fmt = AV_PIX_FMT_MONOBLACK;
 +            break;
 +        }
 +    case 21:
 +    case 41:
 +        s->avctx->pix_fmt = AV_PIX_FMT_PAL8;
 +        if (!s->palette_is_set) {
 +            create_gray_palette = 1;
 +        }
          break;
      case 81:
          s->avctx->pix_fmt = s->palette_is_set ? AV_PIX_FMT_PAL8 : AV_PIX_FMT_GRAY8;