mkvparser: ignore 0-size elements in TrackEntry
ParseTrackEntry handled MKVs with 0-sized EBML elements as malformed. Relaxing this and allow empty elements to allow parsing such MKV content. Change-Id: I7e430e9b2d177df7fe1e656546f63ee8673e784e
This commit is contained in:
@@ -6533,35 +6533,29 @@ long Tracks::ParseTrackEntry(
|
||||
if (status < 0) //error
|
||||
return status;
|
||||
|
||||
if (size < 0)
|
||||
return E_FILE_FORMAT_INVALID;
|
||||
|
||||
const long long start = pos;
|
||||
|
||||
if (id == 0x60) // VideoSettings ID
|
||||
{
|
||||
if (size <= 0)
|
||||
return E_FILE_FORMAT_INVALID;
|
||||
|
||||
v.start = start;
|
||||
v.size = size;
|
||||
}
|
||||
else if (id == 0x61) // AudioSettings ID
|
||||
{
|
||||
if (size <= 0)
|
||||
return E_FILE_FORMAT_INVALID;
|
||||
|
||||
a.start = start;
|
||||
a.size = size;
|
||||
}
|
||||
else if (id == 0x2D80) // ContentEncodings ID
|
||||
{
|
||||
if (size <= 0)
|
||||
return E_FILE_FORMAT_INVALID;
|
||||
|
||||
e.start = start;
|
||||
e.size = size;
|
||||
}
|
||||
else if (id == 0x33C5) //Track UID
|
||||
{
|
||||
if ((size <= 0) || (size > 8))
|
||||
if (size > 8)
|
||||
return E_FILE_FORMAT_INVALID;
|
||||
|
||||
info.uid = 0;
|
||||
@@ -6637,28 +6631,28 @@ long Tracks::ParseTrackEntry(
|
||||
info.codecPrivate = NULL;
|
||||
info.codecPrivateSize = 0;
|
||||
|
||||
if (size <= 0)
|
||||
return E_FILE_FORMAT_INVALID;
|
||||
|
||||
const size_t buflen = static_cast<size_t>(size);
|
||||
|
||||
typedef unsigned char* buf_t;
|
||||
|
||||
const buf_t buf = new (std::nothrow) unsigned char[buflen];
|
||||
|
||||
if (buf == NULL)
|
||||
return -1;
|
||||
|
||||
const int status = pReader->Read(pos, buflen, buf);
|
||||
|
||||
if (status)
|
||||
if (buflen)
|
||||
{
|
||||
delete[] buf;
|
||||
return status;
|
||||
}
|
||||
typedef unsigned char* buf_t;
|
||||
|
||||
info.codecPrivate = buf;
|
||||
info.codecPrivateSize = buflen;
|
||||
const buf_t buf = new (std::nothrow) unsigned char[buflen];
|
||||
|
||||
if (buf == NULL)
|
||||
return -1;
|
||||
|
||||
const int status = pReader->Read(pos, buflen, buf);
|
||||
|
||||
if (status)
|
||||
{
|
||||
delete[] buf;
|
||||
return status;
|
||||
}
|
||||
|
||||
info.codecPrivate = buf;
|
||||
info.codecPrivateSize = buflen;
|
||||
}
|
||||
}
|
||||
else if (id == 0x058688) //Codec Name
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user