From patchwork Thu Sep 5 20:16:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 14940 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 58D9544832D for ; Thu, 5 Sep 2019 23:31:37 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3EA99687F81; Thu, 5 Sep 2019 23:31:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1DEFF687F37 for ; Thu, 5 Sep 2019 23:31:31 +0300 (EEST) Received: by mail-wm1-f67.google.com with SMTP id t17so4217355wmi.2 for ; Thu, 05 Sep 2019 13:31:31 -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:mime-version :content-transfer-encoding; bh=x0EpI5kWTmKCfanNY8YwEEZ38JQlD2hWvP9oRunIF5M=; b=ewD1tjs8T9WsumN9BUgrelSvDW8JmkJZvgYX7oItL8gioNwlzwBh0SRtbL89Bzy0Tt C1OD9QdguAp39PJiPYQ3Ntw6nrgBG/CaOYTk1d+nsHlpSnu+7bXB1smp66k5nK+rm7DM pNyJdHZwPMcKNFheTWdmufB7koL31JNV3Zgs3yxelcZA4D+cb1sxZE5RT4NXQImfL1/r iAu4mGpzoVHwJDBv0nL21slS6awhtgy01pnvzlVmLwJfKj7RAXm6ZsrxjKHOY9WKR4tB db6NALK3GTxcNbDlp1eq0MgitzwxZWW3O+CHD1LrgJHeI6xaoRSqzGGdSiKpHBrLzlzY 4D2w== 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:mime-version :content-transfer-encoding; bh=x0EpI5kWTmKCfanNY8YwEEZ38JQlD2hWvP9oRunIF5M=; b=mnxU5kpXc7GiTyxrw1Vl496VfZM2jCREFTq6lipzvkgLxThXG5KS6jNqJlMHrI0YJp VSuyxi94uaN0HGvzLzJBSfFPD+oEa6JGa2WCP28+dK1AB/rLtMnURMuVKzkJSAJ1mJNx 3KMKD+ZSeONHao0+kjKxNlzOmBwgzwqvxRB0ft8Aig7cPnikM21269angxtQP6tJo22v pSNsfXNwPvFy6KTdZBgsoCUrJ0d4E6aFgvnXE2dLgMfQX3nMnk/JHxBU88h5ZCP+vl58 Ctr4TAAvx0fyjRFDJWOBL4n0/y4gxsIwcUobf8NFj0UYuxAP2vPs0EuyiYiAom511DD+ VtPw== X-Gm-Message-State: APjAAAV2u+T6x1Cjtn80SFR5/j7C+f31CmrKlpPtDuqRED1LuzJIErJg JtaNn9TA2TzFys0p5/u98zUdTN/mARg= X-Google-Smtp-Source: APXvYqzNHiScn7fhSELluGoDbQxRNpLQSKG6wjYAuyx31Y9vsyMQLTlfTPYWMBEwsYXrZeSGg2jqPg== X-Received: by 2002:a7b:cd17:: with SMTP id f23mr4518726wmj.177.1567715031807; Thu, 05 Sep 2019 13:23:51 -0700 (PDT) Received: from localhost.localdomain (ipbcc0f857.dynamic.kabel-deutschland.de. [188.192.248.87]) by smtp.gmail.com with ESMTPSA id g201sm5889769wmg.34.2019.09.05.13.23.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2019 13:23:51 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Sep 2019 22:16:02 +0200 Message-Id: <20190905201609.998-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/8] avformat/matroskadec: Don't overlook parsing error 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 one isn't in a cluster initially, matroska_parse_cluster would test whether the next element is a cluster. Said test can fail and if it failed, the error would be returned until 71c90881. But 71c90881 changed this inadvertently: If the element found is an unknown-length element that is intended to be skipped, but can't (because of its unknown length), it is entered and if an error happens during parsing its children, it is possible that one is on level 2 after the initial test. This will then be treated as if one were inside a cluster and an attempt is made to parse SimpleBlocks/BlockGroups in which case the original error will be overwritten and overlooked. This commit fixes this. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 8c4ff30935..0c881a67e8 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3686,9 +3686,9 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) cluster->pos = avio_tell(matroska->ctx->pb) - 4; res = ebml_parse(matroska, matroska_cluster_enter, cluster); - if (res < 0) - return res; } + if (res < 0) + return res; } if (matroska->num_levels == 2) {