summaryrefslogtreecommitdiff
path: root/libavformat/matroskadec.c
diff options
context:
space:
mode:
authorThomas Guillem <thomas@gllm.fr>2015-04-10 19:04:51 +0200
committerAnton Khirnov <anton@khirnov.net>2015-04-18 16:49:25 +0200
commitb8d7f3186e86234f6255f5e8ee9e98573b4d9a6e (patch)
tree2558ab3a4b2ea16023e9c8b7227b8efbf6cc3c5a /libavformat/matroskadec.c
parent1336bb06c9fbf9a14765e9f78616f2aad4f3a45a (diff)
matroskadec: fix crash when parsing invalid mkv
CC: libav-stable@libav.org Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavformat/matroskadec.c')
-rw-r--r--libavformat/matroskadec.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 7dac7beb99..93cd4bbb1c 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1827,8 +1827,12 @@ static int matroska_read_header(AVFormatContext *s)
matroska->ctx = s;
/* First read the EBML header. */
- if (ebml_parse(matroska, ebml_syntax, &ebml) ||
- ebml.version > EBML_VERSION ||
+ if (ebml_parse(matroska, ebml_syntax, &ebml) || !ebml.doctype) {
+ av_log(matroska->ctx, AV_LOG_ERROR, "EBML header parsing failed\n");
+ ebml_free(ebml_syntax, &ebml);
+ return AVERROR_INVALIDDATA;
+ }
+ if (ebml.version > EBML_VERSION ||
ebml.max_size > sizeof(uint64_t) ||
ebml.id_length > sizeof(uint32_t) ||
ebml.doctype_version > 3) {