• Andreas Rheinhardt's avatar
    avformat/matroskadec: Don't discard valid packets · e471faf9
    Andreas Rheinhardt authored
    A Block (meaning both a Block in a BlockGroup as well as a SimpleBlock)
    must have at least three bytes after the field containing the encoded
    TrackNumber. So if there are <= 3 bytes, the Matroska demuxer would
    skip this block, believing it to be an empty, but valid Block.
    
    This might discard valid nonempty Blocks, namely if the track uses header
    stripping. And certain definitely spec-incompliant Blocks don't raise
    errors: Those with two or less bytes left after the encoded TrackNumber
    and those with three bytes left, but with flags indicating that the Block
    uses lacing as then there has to be further data describing the lacing.
    
    Furthermore, zero-sized packets were still possible because only the
    size of the last entry of a lace was checked.
    
    This commit fixes this. All spec-compliant Blocks that contain data
    (even if side data only) are now returned to the caller; spec-compliant
    Blocks that don't contain anything are not returned.
    Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
    e471faf9
matroskadec.c 158 KB