summaryrefslogtreecommitdiff
path: root/libavformat/matroskadec.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-11-15 10:15:24 +0100
committerAnton Khirnov <anton@khirnov.net>2013-11-21 20:54:30 +0100
commit30be1ea33e5525266ad871bed60b1893a53caeaf (patch)
tree061f9bea048a433fdf46085403dc5011e53ce2d4 /libavformat/matroskadec.c
parentf0259a587ee3419dd894873ea617b4c98eeaca1c (diff)
matroskadec: pad EBML_BIN data.
It might be passed to code requiring padding, such as lzo decompression. Fixes invalid reads. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC:libav-stable@libav.org
Diffstat (limited to 'libavformat/matroskadec.c')
-rw-r--r--libavformat/matroskadec.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index f798342443..764dbf82b9 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -734,9 +734,11 @@ static int ebml_read_ascii(AVIOContext *pb, int size, char **str)
static int ebml_read_binary(AVIOContext *pb, int length, EbmlBin *bin)
{
av_free(bin->data);
- if (!(bin->data = av_malloc(length)))
+ if (!(bin->data = av_malloc(length + FF_INPUT_BUFFER_PADDING_SIZE)))
return AVERROR(ENOMEM);
+ memset(bin->data + length, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+
bin->size = length;
bin->pos = avio_tell(pb);
if (avio_read(pb, bin->data, length) != length) {