[SCM] libav/experimental: Reallocate internal buffer when coded frame size changes. Fixes out-of-bounds reads and writes with i32/smclocki32.avi.1.0 from issue 1240.

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 16:48:38 UTC 2013


The following commit has been merged in the experimental branch:
commit 16c831851384ab59e73579fdd9913fbff3c0284a
Author: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
Date:   Mon Jul 6 16:48:23 2009 +0000

    Reallocate internal buffer when coded frame size changes.
    Fixes out-of-bounds reads and writes with i32/smclocki32.avi.1.0 from issue 1240.
    
    Originally committed as revision 19359 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c
index 7e4cd96..9c14e81 100644
--- a/libavcodec/indeo3.c
+++ b/libavcodec/indeo3.c
@@ -107,6 +107,7 @@ static av_cold int iv_alloc_frames(Indeo3DecodeContext *s)
     unsigned int bufsize = luma_pixels * 2 + luma_width * 3 +
                           (chroma_pixels   + chroma_width) * 4;
 
+    av_freep(&s->buf);
     if(!(s->buf = av_malloc(bufsize)))
         return AVERROR(ENOMEM);
     s->iv_frame[0].y_w = s->iv_frame[1].y_w = luma_width;
@@ -997,6 +998,17 @@ static int iv_decode_frame(AVCodecContext *avctx,
 
     if(avcodec_check_dimensions(avctx, image_width, image_height))
         return -1;
+    if (image_width != avctx->width || image_height != avctx->height) {
+        int ret;
+        avcodec_set_dimensions(avctx, image_width, image_height);
+        s->width  = avctx->width;
+        s->height = avctx->height;
+        ret = iv_alloc_frames(s);
+        if (ret < 0) {
+            s->width = s->height = 0;
+            return ret;
+        }
+    }
 
     chroma_height = ((image_height >> 2) + 3) & 0x7ffc;
     chroma_width = ((image_width >> 2) + 3) & 0x7ffc;

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list