]> git.sesse.net Git - ffmpeg/commitdiff
dfa: check that the caller set width/height properly.
authorAnton Khirnov <anton@khirnov.net>
Fri, 28 Sep 2012 12:47:56 +0000 (14:47 +0200)
committerAnton Khirnov <anton@khirnov.net>
Sat, 29 Sep 2012 07:27:08 +0000 (09:27 +0200)
Fixes CVE-2012-2786.

libavcodec/dfa.c

index 5beae7f1a4fbe3b35ec71ebc6e76fc19d9c3069a..c6f09c89a72280754f5cc697f607f763a9dcb9a2 100644 (file)
@@ -22,6 +22,8 @@
 
 #include "avcodec.h"
 #include "bytestream.h"
+
+#include "libavutil/imgutils.h"
 #include "libavutil/lzo.h" // for av_memcpy_backptr
 
 typedef struct DfaContext {
@@ -34,9 +36,13 @@ typedef struct DfaContext {
 static av_cold int dfa_decode_init(AVCodecContext *avctx)
 {
     DfaContext *s = avctx->priv_data;
+    int ret;
 
     avctx->pix_fmt = PIX_FMT_PAL8;
 
+    if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
+        return ret;
+
     s->frame_buf = av_mallocz(avctx->width * avctx->height + AV_LZO_OUTPUT_PADDING);
     if (!s->frame_buf)
         return AVERROR(ENOMEM);