Ticket #581: 0001-matroskadec-Zero-length-in-the-no-lacing-case-is-val.patch

File 0001-matroskadec-Zero-length-in-the-no-lacing-case-is-val.patch, 1.5 KB (added by Chris Wulff, 15 years ago)
  • libavformat/matroskadec.c

    From 604e0c31b2e6a157a74b98e4015ec3c151ba9716 Mon Sep 17 00:00:00 2001
    From: Chris Wulff <chris.wulff@labxtechnologies.com>
    Date: Sat, 22 Oct 2011 09:29:12 -0400
    Subject: [PATCH] matroskadec: Zero length in the "no lacing" case is valid
     (sometimes present in subtitle tracks.)
    
    ---
     libavformat/matroskadec.c |    8 ++++++--
     1 files changed, 6 insertions(+), 2 deletions(-)
    
    diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
    index 78e337b..b1475fc 100644
    a b static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,  
    17501750    size -= n;
    17511751
    17521752    track = matroska_find_track_by_num(matroska, num);
    1753     if (size <= 3 || !track || !track->stream) {
     1753    if (size < 3 || !track || !track->stream) {
    17541754        av_log(matroska->ctx, AV_LOG_INFO,
    17551755               "Invalid stream %"PRIu64" or size %u\n", num, size);
    17561756        return AVERROR_INVALIDDATA;
    static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,  
    17951795        case 0x1: /* Xiph lacing */
    17961796        case 0x2: /* fixed-size lacing */
    17971797        case 0x3: /* EBML lacing */
    1798             assert(size>0); // size <=3 is checked before size-=3 above
     1798            if (size < 1) {
     1799                av_log(matroska->ctx, AV_LOG_INFO,
     1800                       "Lacing header missing: size %u\n", size);
     1801                return AVERROR_INVALIDDATA;
     1802            }
    17991803            laces = (*data) + 1;
    18001804            data += 1;
    18011805            size -= 1;