From patchwork Sat Feb 23 10:14:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Lhomme X-Patchwork-Id: 12147 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 9FEFA448493 for ; Sat, 23 Feb 2019 12:15:03 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 83EAB689DD1; Sat, 23 Feb 2019 12:15:03 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mx2.mailbox.org (mx2.mailbox.org [80.241.60.215]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C6F97689AC1 for ; Sat, 23 Feb 2019 12:14:56 +0200 (EET) Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 4826CA0C0C; Sat, 23 Feb 2019 11:14:55 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ycbcr.xyz; s=MBO0001; t=1550916893; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=zi5sMctQ3cCzg4bV/+k8/XcbY53cUyityAVpDJ8ILbk=; b=YpLHX4n/1zsskEo2YwBcQddYPrg+5aJwYrYXIqltgdHxa32Ne059iUS1p+yrcK/07HzWLc iUPDGwVyRsjvy3IEDml64LL/D2zZTci47CBkxHvKbPy1xKPd/Xyib6bjXfk+TkpWUr1wjr OdttleNAxyYnnChYJriY2h1QIjxAp9XTexfP59TyZFNgXTWGIJJxIx/+jooUpW/zIvXj6V +/JYWP6AnGWVAvjZ7L2fi34pU1hUxYfOlF7My6/BV5mPghKPGLh7mpWvxG88S31likz3ee aoZ8txUMClmsH01Ewa4A1jkcPldjyIMSUpG4jp1nDeDW3ty+AEx/NyggBpsIbA== Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id EgeOHbp8VGtL; Sat, 23 Feb 2019 11:14:42 +0100 (CET) From: Steve Lhomme To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Feb 2019 11:14:33 +0100 Message-Id: <20190223101433.11520-1-robUx4@ycbcr.xyz> Authentication-Results: default_out X-Rspamd-Queue-Id: 1795C16AC Subject: [FFmpeg-devel] [PATCH] avformat:matroskadec: use a define to mark the EBML length is unknown X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Steve Lhomme MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Steve Lhomme --- libavformat/matroskadec.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 5aa8a105dc..0e3a6890c1 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -68,6 +68,8 @@ #include "qtpalette.h" +#define EBML_UNKNOWN_LENGTH UINT64_MAX /* EBML unknown length, in uint64_t */ + typedef enum { EBML_NONE, EBML_UINT, @@ -869,7 +871,7 @@ static int ebml_read_length(MatroskaDemuxContext *matroska, AVIOContext *pb, { int res = ebml_read_num(matroska, pb, 8, number); if (res > 0 && *number + 1 == 1ULL << (7 * res)) - *number = 0xffffffffffffffULL; + *number = EBML_UNKNOWN_LENGTH; return res; } @@ -1049,7 +1051,7 @@ static int ebml_parse_id(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, break; if (!syntax[i].id && id == MATROSKA_ID_CLUSTER && matroska->num_levels > 0 && - matroska->levels[matroska->num_levels - 1].length == 0xffffffffffffff) + matroska->levels[matroska->num_levels - 1].length == EBML_UNKNOWN_LENGTH) return 0; // we reached the end of an unknown size cluster if (!syntax[i].id && id != EBML_ID_VOID && id != EBML_ID_CRC32) { av_log(matroska->ctx, AV_LOG_DEBUG, "Unknown entry 0x%"PRIX32"\n", id); @@ -1201,7 +1203,7 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska, MatroskaLevel *level = &matroska->levels[matroska->num_levels - 1]; AVIOContext *pb = matroska->ctx->pb; int64_t pos = avio_tell(pb); - if (level->length != (uint64_t) -1 && + if (level->length != EBML_UNKNOWN_LENGTH && (pos + length) > (level->start + level->length)) { av_log(matroska->ctx, AV_LOG_ERROR, "Invalid length 0x%"PRIx64" > 0x%"PRIx64" in parent\n", @@ -1610,7 +1612,7 @@ static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska, ret = AVERROR_INVALIDDATA; } else { level.start = 0; - level.length = (uint64_t) -1; + level.length = EBML_UNKNOWN_LENGTH; matroska->levels[matroska->num_levels] = level; matroska->num_levels++; matroska->current_id = 0; @@ -1620,7 +1622,7 @@ static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska, /* remove dummy level */ while (matroska->num_levels) { uint64_t length = matroska->levels[--matroska->num_levels].length; - if (length == (uint64_t) -1) + if (length == EBML_UNKNOWN_LENGTH) break; } }