From d13c0177449f66c87ddaafe3c62e3241d17267ba Mon Sep 17 00:00:00 2001 From: Vignesh Venkatasubramanian Date: Fri, 16 May 2014 11:25:22 -0700 Subject: [PATCH] UUIDs can have their high bit set mkvparser::UnserializeUInt() assumes that unsigned values never have their high bit set. This is too limiting for UUIDs. In addition, the Chapters::Atom::Parse() method would truncate a "negative" 64-bit UUID value to 32 bits and return the truncated value as a status code. This value then might or might not be treated as an error by the caller depending on whether the truncated value was itself negative. Change-Id: I15624ac62d0b02691a1405ee6a5f7eb441b3bc48 --- mkvparser.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mkvparser.cpp b/mkvparser.cpp index 441f165..3298fc4 100644 --- a/mkvparser.cpp +++ b/mkvparser.cpp @@ -130,6 +130,8 @@ long long mkvparser::GetUIntLength(IMkvReader* pReader, long long pos, return 0; // success } +// TODO(vigneshv): This function assumes that unsigned values never have their +// high bit set. long long mkvparser::UnserializeUInt(IMkvReader* pReader, long long pos, long long size) { assert(pReader); @@ -4128,12 +4130,13 @@ long Chapters::Atom::Parse(IMkvReader* pReader, long long pos, long long size) { if (status < 0) // error return status; } else if (id == 0x33C4) { // UID ID - const long long val = UnserializeUInt(pReader, pos, size); + long long val; + status = UnserializeInt(pReader, pos, size, val); if (val < 0) // error - return static_cast(val); + return status; - m_uid = val; + m_uid = static_cast(val); } else if (id == 0x11) { // TimeStart ID const long long val = UnserializeUInt(pReader, pos, size);