From patchwork Thu May 16 22:30:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 13158 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 4596F44966A for ; Fri, 17 May 2019 01:45:52 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E934068A5B5; Fri, 17 May 2019 01:43:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DEF21689998 for ; Fri, 17 May 2019 01:43:33 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id x64so5105494wmb.5 for ; Thu, 16 May 2019 15:43:33 -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=V6cTq4zwE1vWuW2RjlmQDrzo9Ml/6n62qPTnMB70sec=; b=rnr1nW+sMDp0tQazjNf5gsX+y53ystg51idn4AuiBAkCOaK1pq74Tb6V8gjq5x3k5E UFbuD8sCDAscCMpAxVV0E6SaqGsKApuhy9W315ycpTVOpP67qF22S+PyOH9n0nHH5LXP fqdIWu0lSF7seKzYMaNw3j1rHYyfqsBzcSmzBluzv620qtHOXjyrX28EbcIiET83iYtb 9C6Kmyzrcp71vhDi0lJDnWEUUsCrwAvGuEoHQ/8Wh0Vl5MQ62/NLyrCrukAg8S4czrAt RtCrqFJGQhddOGHC01mtrBy9W8gwYjVuVXb+Ui5k1U6BOETUSYKbjcq6G9kOaKIN/uHr g97w== 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=V6cTq4zwE1vWuW2RjlmQDrzo9Ml/6n62qPTnMB70sec=; b=Vrajh/WMUPYJQfDOBInzoGGxN9riMgoLOnl0qwNI3RU6ich0mFEj8krJVBPg33FHrV 6DzDNZfTm/hIpOzO+XU7t4bKHddwSpzVcHQSiqz5j6mSLyrKwPKLSoKL/5IB6KYpActD qKvPYCywFqpoZ8vXTlzYCTrIMhS0cqf/gNA/L/gIzu3t2KirNXumrjCgbb+vnx5xsxR0 p+ia5Zn9zA1qFz+IrdEcdA3IUfVszpRbixOudxKZssRnOFvbTRvxsk8XB0V2OAuX+3a1 Kc0r0dy4UBwpUHHWfy+7DK3H6CMNrhA20Yx4NWaRiaHr9WCcWUbjdU5CHnbClJWj5/ys 9VeA== X-Gm-Message-State: APjAAAX+cOEAagDIYJKtT5jhS1SyRA4BPNbpDSNQBA3hZwi19OWEBR93 ZQZg5HIaLfUhHslEm2LjIxglWx64 X-Google-Smtp-Source: APXvYqx4YVNUW/5g+cTZdcpOwU7n77ILh0OhhkC8R012x5NKO6DByJlaUCEXATq65tbZ/aD7/H9/5g== X-Received: by 2002:a1c:6a0e:: with SMTP id f14mr108405wmc.28.1558046613270; Thu, 16 May 2019 15:43:33 -0700 (PDT) Received: from localhost.localdomain (ipbcc18715.dynamic.kabel-deutschland.de. [188.193.135.21]) by smtp.gmail.com with ESMTPSA id i185sm11168725wmg.32.2019.05.16.15.43.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 May 2019 15:43:32 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 17 May 2019 00:30:21 +0200 Message-Id: <20190516223018.30827-38-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516223018.30827-1-andreas.rheinhardt@gmail.com> References: <20190516223018.30827-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 37/37] avformat/matroskadec: Improve check for level 1 duplicates 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" If a file uses unknown-length level 1 elements besides clusters and such elements are after the first cluster, then these elements will usually be parsed twice: Once during parsing of the file header and once when reading the file reaches the position where these elements are located. The second time the element is parsed leads to a "Duplicate element" error message. Known-length elements are not affected by this as they are skipped except during parsing the header. This commit fixes this by explicitly adding a check for whether the position of the element to be parsed is the same as the position of the already known level 1 element. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 0bf6477b0e..a4ba9720c6 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1386,7 +1386,10 @@ static int ebml_parse(MatroskaDemuxContext *matroska, matroska->cues_parsing_deferred = 0; if (syntax->type == EBML_LEVEL1 && (level1_elem = matroska_find_level1_elem(matroska, syntax->id))) { - if (level1_elem->parsed) + if (!level1_elem->pos) { + // Zero is not a valid position for a level 1 element. + level1_elem->pos = pos; + } else if (level1_elem->pos != pos) av_log(matroska->ctx, AV_LOG_ERROR, "Duplicate element\n"); level1_elem->parsed = 1; }