]> git.sesse.net Git - ffmpeg/commitdiff
matroska: Update the available size after lace parsing
authorDale Curtis <dalecurtis@chromium.org>
Wed, 27 Mar 2013 21:02:03 +0000 (14:02 -0700)
committerLuca Barbato <lu_zero@gentoo.org>
Wed, 3 Apr 2013 10:33:01 +0000 (12:33 +0200)
Fix heap-buffer-overflow in matroska_parse_block for
corrupted real media in mkv files.

CC: libav-stable@libav.org
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
libavformat/matroskadec.c

index 4a872b8dc80ce36755487526118a03546ae017ec..2ec669f005040707ae3548696b8ee49b5e2cb7c1 100644 (file)
@@ -1756,10 +1756,10 @@ static void matroska_clear_queue(MatroskaDemuxContext *matroska)
 }
 
 static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
-                                int size, int type,
+                                int* buf_size, int type,
                                 uint32_t **lace_buf, int *laces)
 {
-    int res = 0, n;
+    int res = 0, n, size = *buf_size;
     uint8_t *data = *buf;
     uint32_t *lace_size;
 
@@ -1857,6 +1857,7 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
 
     *buf      = data;
     *lace_buf = lace_size;
+    *buf_size = size;
 
     return res;
 }
@@ -2051,7 +2052,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
         matroska->skip_to_keyframe = 0;
     }
 
-    res = matroska_parse_laces(matroska, &data, size, (flags & 0x06) >> 1,
+    res = matroska_parse_laces(matroska, &data, &size, (flags & 0x06) >> 1,
                                &lace_size, &laces);
 
     if (res)