Code: long Cluster::ParseSimpleBlock(
    long long block_size,
    long long& pos,
    long& len)
{
    const long long block_start = pos;
    const long long block_stop = pos + block_size;
    IMkvReader* const pReader = m_pSegment->m_pReader;
    long long total, avail;
    long status = pReader->Length(&total, &avail);
    if (status < 0)  //error
        return status;
    assert((total < 0) || (avail <= total));
    if ((pos + 1) > avail)
    {
        len = 1;
        return E_BUFFER_NOT_FULL;
     }
 
     long long result = GetUIntLength(pReader, pos, len);
 
    if (result < 0)  //error
        return static_cast<long>(result);
 
    if (result > 0)  //weird
        return E_BUFFER_NOT_FULL;
 
    if ((pos + len) > block_stop)
        return E_FILE_FORMAT_INVALID;
 
     if ((pos + len) > avail)
         return E_BUFFER_NOT_FULL;
 
    const long long track = ReadUInt(pReader, pos, len);
 
    if (track < 0) //error
        return static_cast<long>(track);
 
    if (track == 0)
        return E_FILE_FORMAT_INVALID;
 
 #if 0

 const Tracks* const pTracks = m_pSegment->GetTracks();
    assert(pTracks);

 const long tn = static_cast<long>(track);

 const Track* const pTrack = pTracks->GetTrackByNumber(tn);

 if (pTrack == NULL)

         return E_FILE_FORMAT_INVALID;
 #endif
 
    pos += len;  //consume track number
 
    if ((pos + 2) > block_stop)
        return E_FILE_FORMAT_INVALID;
 
    if ((pos + 2) > avail)
    {
        len = 2;
        return E_BUFFER_NOT_FULL;
    }
 
    pos += 2;  //consume timecode
 
    if ((pos + 1) > block_stop)
        return E_FILE_FORMAT_INVALID;
 
    if ((pos + 1) > avail)
    {
        len = 1;
        return E_BUFFER_NOT_FULL;
    }
 
    unsigned char flags;
 
    status = pReader->Read(pos, 1, &flags);
 
    if (status < 0)  //error or underflow
    {
        len = 1;
        return status;
    }
 
    ++pos;  //consume flags byte
    assert(pos <= avail);
 
    if (pos >= block_stop)
        return E_FILE_FORMAT_INVALID;
 
    const int lacing = int(flags & 0x06) >> 1;
 
    if ((lacing != 0) && (block_stop > avail))
    {
        len = static_cast<long>(block_stop - pos);
        return E_BUFFER_NOT_FULL;
    }
 
    status = CreateBlock(0x23,  //simple block id
                         block_start, block_size,
                         0);  //DiscardPadding
 
    if (status != 0)
        return status;
 
    m_pos = block_stop;
 
    return 0;  //success
 }

Vulnerability Type: DoS Exec Code Overflow Mem. Corr. 
CWE ID: CWE-119
Summary: libvpx in mediaserver in Android 4.x before 4.4.4, 5.x before 5.1.1 LMY49H, and 6.0 before 2016-03-01 allows remote attackers to execute arbitrary code or cause a denial of service (memory corruption) via a crafted media file, related to libwebm/mkvparser.cpp and other files, aka internal bug 23452792.
Commit Message: libwebm: Pull from upstream

Rolling mkvparser from upstream. Primarily for fixing a bug on parsing
failures with certain Opus WebM files.

Upstream commit hash of this pull: 574045edd4ecbeb802ee3f1d214b5510269852ae

The diff is so huge because there were some style clean ups upstream.
But it was ensured that there were no breaking changes when the style
clean ups was done upstream.

Change-Id: Ib6e907175484b4b0ae1b55ab39522ea3188ad039