huffyuvdec: check width size for yuv422p
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 2 Aug 2014 23:54:33 +0000 (00:54 +0100)
committerAnton Khirnov <anton@khirnov.net>
Tue, 5 Aug 2014 20:01:59 +0000 (20:01 +0000)
Avoid out of array accesses.

CC: libav-stable@libav.org
Bug-Id: CVE-2013-0848
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
libavcodec/huffyuvdec.c

index dc99d19a62dbd1e0f72e53e68b61e05b82635e43..d8f31d3dd79bebf0d2b26046a1e7b59dc159e664 100644 (file)
@@ -341,6 +341,13 @@ static av_cold int decode_init(AVCodecContext *avctx)
         return AVERROR_INVALIDDATA;
     }
 
+    if (s->predictor == MEDIAN && avctx->pix_fmt == AV_PIX_FMT_YUV422P &&
+        avctx->width % 4) {
+        av_log(avctx, AV_LOG_ERROR, "width must be multiple of 4 "
+               "for this combination of colorspace and predictor type.\n");
+        return AVERROR_INVALIDDATA;
+    }
+
     if ((ret = ff_huffyuv_alloc_temp(s)) < 0)
         return ret;