From patchwork Fri Aug 16 03:05:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 14547 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 47B8E448270 for ; Fri, 16 Aug 2019 06:20:44 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 30C3668AD40; Fri, 16 Aug 2019 06:20:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E807F68ACF2 for ; Fri, 16 Aug 2019 06:20:37 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id q12so151501wrj.12 for ; Thu, 15 Aug 2019 20:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rVTCCjlhdcSXBk8kcxlA5mGSi2ErkSLPJv51virAwA0=; b=itv3TnjJ+YeKE2Jbl3KZ+xFX817dm2JVGM5u8ktKnYah7HthGG6zDvSfSiCKJX3Yiv 4wu6iola75+w6C4pLemugBpLNWj82cKeg+myUJ8n6UDNsUcaiykuwYhbRiQh/iVZMKvu k9uuQVBJs+YyAwbOHXMpzG2f015ut7EYA2p48XmWnKvQ3bI3rk0zKVJ0SDTawu3r7hzm PAkD0DlMXQiUxWyAn/W4Z6msrSrjlg8Yvvtaq8O4bfUsL2HHsUimgWT+2fpZK0x/tPwy hl6qikrmAmhLj+wNCsGCmpB4OIM7bb6I/CfcTVXi0MGkGIIywvnlMgcoZ5GLJeh9FLcV WbTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rVTCCjlhdcSXBk8kcxlA5mGSi2ErkSLPJv51virAwA0=; b=itNxE1PQ90xgsR3skYVJ6qMZ0TRboNxsjJUGwBha33colPXlLGTW6LGY7TVzZBZhNL 4oAIgJWXj02tC00zgietOF39++B8Kg7r62UFOcmo5smIb34qGNrIATkT33bQ6Q3CF8TH mc5qLiZlw2pl7XKs2uSENcvNC8aiC1UHSQNB82SxZyefCCyojAepx7Lwurdcd5/UV2E7 h0myu1JVRHpRA5nnFrNqPXOR/+enxpcaxD5eSsF23ohY76mMj6p7raYIVpgeb3qjd9zQ pzqDVFQaiOUlHpkdgbs5H9q9jLdJKSm5355BgFHPZxJ9XXeV0CEoF+CdghRkS4fX7VZP 3amA== X-Gm-Message-State: APjAAAUoxgANvJ03cLifJ/k0HkFLmtZblJfKsoaLOV6elpRacGCgMBaF HAv8QmeVd8gaLzvqBj9krDAUZfVn X-Google-Smtp-Source: APXvYqwmTpXMUPXtt/lSBNPfie02ZWa/WuUAg379ZGW1HSl1ZkaqCN8H8fBS4+lqiZfSAEvlpsWhlQ== X-Received: by 2002:a5d:4108:: with SMTP id l8mr7817188wrp.113.1565925227008; Thu, 15 Aug 2019 20:13:47 -0700 (PDT) Received: from localhost.localdomain (ipbcc08b69.dynamic.kabel-deutschland.de. [188.192.139.105]) by smtp.gmail.com with ESMTPSA id x20sm8501603wrg.10.2019.08.15.20.13.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2019 20:13:46 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Aug 2019 05:05:23 +0200 Message-Id: <20190816030531.4775-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190816030531.4775-1-andreas.rheinhardt@gmail.com> References: <20190816030531.4775-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/11] avformat/matroskadec: Improve frame size parsing error messages 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" When parsing the sizes of the frames in a lace fails, sometimes no error message was raised (e.g. when using xiph or fixed-size lacing). Only EBML lacing generated error messages (which were wrongly declared as AV_LOG_INFO), but even here not all errors resulted in an error message. So add a generic error message to catch them all. Moreover, if parsing one of the EBML numbers fails, ebml_read_num already emits its own error messages, so that all that is needed is a generic error message to indicate that this happened during parsing the sizes of the frames in a block; in other words, the error messages specific to parsing EBML lace numbers can be and have been removed. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 5901dbd221..c9fe795dcd 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3064,11 +3064,10 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, uint64_t num; uint64_t total; n = matroska_ebmlnum_uint(matroska, data, size, &num); - if (n < 0 || num > INT_MAX) { - av_log(matroska->ctx, AV_LOG_INFO, - "EBML block data error\n"); - return n<0 ? n : AVERROR_INVALIDDATA; - } + if (n < 0) + return n; + if (num > INT_MAX) + return AVERROR_INVALIDDATA; data += n; size -= n; total = lace_size[0] = num; @@ -3076,11 +3075,10 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, int64_t snum; int r; r = matroska_ebmlnum_sint(matroska, data, size, &snum); - if (r < 0 || lace_size[n - 1] + snum > (uint64_t)INT_MAX) { - av_log(matroska->ctx, AV_LOG_INFO, - "EBML block data error\n"); - return r<0 ? r : AVERROR_INVALIDDATA; - } + if (r < 0) + return r; + if (lace_size[n - 1] + snum > (uint64_t)INT_MAX) + return AVERROR_INVALIDDATA; data += r; size -= r; lace_size[n] = lace_size[n - 1] + snum; @@ -3591,8 +3589,10 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf res = matroska_parse_laces(matroska, &data, size, (flags & 0x06) >> 1, &lace_size, &laces); - if (res) + if (res < 0) { + av_log(matroska->ctx, AV_LOG_ERROR, "Error parsing frame sizes.\n"); goto end; + } if (track->audio.samplerate == 8000) { // If this is needed for more codecs, then add them here