From 8376a8e9d759aa40bff05a0b747cc34ae5651664 Mon Sep 17 00:00:00 2001 From: Matthew Heaney Date: Thu, 10 Jan 2013 19:16:58 -0800 Subject: [PATCH] mkvparser: liberalize parsing of bad elements Normally, if a sub-element of a cluster reports a size that lies beyond the end of its enclosing cluster, we would treat this as a malformed stream and immediately terminate the parse. However, if the sub-element is not a simple block or block group, we would ignore the (sub)element anyway, so there doesn't appear to be any harm in just concontinuing to ignore the (sub)element, and treating this case as if we had reached the end-of-cluster in the normal way. Change-Id: I16c0a44f7458823ed579612d917b09ee08a8d90a --- mkvparser.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mkvparser.cpp b/mkvparser.cpp index da12756..0216d58 100644 --- a/mkvparser.cpp +++ b/mkvparser.cpp @@ -21,7 +21,7 @@ void mkvparser::GetVersion(int& major, int& minor, int& build, int& revision) major = 1; minor = 0; build = 0; - revision = 26; + revision = 27; } long long mkvparser::ReadUInt(IMkvReader* pReader, long long pos, long& len) @@ -7228,7 +7228,13 @@ long Cluster::Parse(long long& pos, long& len) const if (cluster_stop >= 0) { if (block_stop > cluster_stop) - return E_FILE_FORMAT_INVALID; + { + if ((id == 0x20) || (id == 0x23)) + return E_FILE_FORMAT_INVALID; + + pos = cluster_stop; + break; + } } else if ((total >= 0) && (block_stop > total)) {