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
|
if (status < 0) //error
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
if (size < 0)
|
||||||
|
return E_FILE_FORMAT_INVALID;
|
||||||
|
|
||||||
const long long start = pos;
|
const long long start = pos;
|
||||||
|
|
||||||
if (id == 0x60) // VideoSettings ID
|
if (id == 0x60) // VideoSettings ID
|
||||||
{
|
{
|
||||||
if (size <= 0)
|
|
||||||
return E_FILE_FORMAT_INVALID;
|
|
||||||
|
|
||||||
v.start = start;
|
v.start = start;
|
||||||
v.size = size;
|
v.size = size;
|
||||||
}
|
}
|
||||||
else if (id == 0x61) // AudioSettings ID
|
else if (id == 0x61) // AudioSettings ID
|
||||||
{
|
{
|
||||||
if (size <= 0)
|
|
||||||
return E_FILE_FORMAT_INVALID;
|
|
||||||
|
|
||||||
a.start = start;
|
a.start = start;
|
||||||
a.size = size;
|
a.size = size;
|
||||||
}
|
}
|
||||||
else if (id == 0x2D80) // ContentEncodings ID
|
else if (id == 0x2D80) // ContentEncodings ID
|
||||||
{
|
{
|
||||||
if (size <= 0)
|
|
||||||
return E_FILE_FORMAT_INVALID;
|
|
||||||
|
|
||||||
e.start = start;
|
e.start = start;
|
||||||
e.size = size;
|
e.size = size;
|
||||||
}
|
}
|
||||||
else if (id == 0x33C5) //Track UID
|
else if (id == 0x33C5) //Track UID
|
||||||
{
|
{
|
||||||
if ((size <= 0) || (size > 8))
|
if (size > 8)
|
||||||
return E_FILE_FORMAT_INVALID;
|
return E_FILE_FORMAT_INVALID;
|
||||||
|
|
||||||
info.uid = 0;
|
info.uid = 0;
|
||||||
@@ -6637,28 +6631,28 @@ long Tracks::ParseTrackEntry(
|
|||||||
info.codecPrivate = NULL;
|
info.codecPrivate = NULL;
|
||||||
info.codecPrivateSize = 0;
|
info.codecPrivateSize = 0;
|
||||||
|
|
||||||
if (size <= 0)
|
|
||||||
return E_FILE_FORMAT_INVALID;
|
|
||||||
|
|
||||||
const size_t buflen = static_cast<size_t>(size);
|
const size_t buflen = static_cast<size_t>(size);
|
||||||
|
|
||||||
typedef unsigned char* buf_t;
|
if (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;
|
typedef unsigned char* buf_t;
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
info.codecPrivate = buf;
|
const buf_t buf = new (std::nothrow) unsigned char[buflen];
|
||||||
info.codecPrivateSize = 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
|
else if (id == 0x058688) //Codec Name
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user