From: Dale Curtis <[email protected]>

Fix heap-buffer-overflow in matroska_parse_block for
corrupted real media in mkv files.

CC: [email protected]

Signed-off-by: Luca Barbato <[email protected]>
---

I'm not sure if wouldn't be better pass the lace_size to the
matroska_parse_rm_audio and stop using the global size value.

Any rm in mkv expert willing to chip in?

 libavformat/matroskadec.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 4a872b8..2ec669f 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -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)
-- 
1.8.1.5

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to