From patchwork Thu May 16 22:30:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 13161 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 B53DE44966A for ; Fri, 17 May 2019 01:45:19 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0532D68A497; Fri, 17 May 2019 01:43:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 432E668A518 for ; Fri, 17 May 2019 01:43:30 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id j187so8022617wma.1 for ; Thu, 16 May 2019 15:43:30 -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=RPGYWiKxM9dxdJldcR0Mzz3OcdgBMchoS8/fqcniZt8=; b=nlajcDnQwmQDVJYiKVF6UfZs/sb29HvY4G54d8Pjt45fYqSlV8fJxZIDsn+5n0gMVS x8olF0RFD9+5lyeFtCa0DvJEe278NT2RtkA3lSdLIyZ3jo75GNZyq29s2ZmtBQJKKSf+ 2DSjEvON84a7pzE54w6KSQP7f/2/bx9Pf+rRDnkk6ZlyHEuLFLrnDOae+1leCa119Ogs oiEatwYlMadlfGlhMPjTdoy1h3lNB5r1jimPZkBGpGPdUQwI503uqPa93eyudHzrMoA/ ME3TiG3SXHlOBc8RboP1PbfRfwkuRmf2iaAhLvpBP0VPe0bnghvi6fEOxHdNcGKdPn3f /QeA== 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=RPGYWiKxM9dxdJldcR0Mzz3OcdgBMchoS8/fqcniZt8=; b=IKsoPCabQTorGyeKsnEyua/lLCAqB0siotHQSuCecbrBfOqzEG39+afjv/Z8GnzAp1 GNwuxq7C/wJl0v2v9Vfg/LV6ktKHVmZV2EUVkB0zp/nxIqRV6h6+tUtiU1sstD5rzNoU guBBRH/I7vM1BkxPL61/4re9TCtgjHDLx6m0nrOVetdscqdzWTLxaC5wbqSnsj0zSCtw LiYnW2m7UdvDmfLBUN36dkfOvsn0k8AA4ciCKceBW0tdaQsy9ZD1qKTLiYp0pKAkJ2If SEL9lqcO+3nDytQFj9T0VeujGAv/XHFWpxXsbLtmA9s2gTY+unPC7QBmx8z+GBgG4wQr 6Tag== X-Gm-Message-State: APjAAAUayJ4JRv0sVeNjkLuy9vlSn6stdrUjhxHMK7BCCrv68XRMeO+f zTofMvwoDp1ZGK1SxkY1BM5cXg2K X-Google-Smtp-Source: APXvYqzFpInj05QE9bdlDI4S7bXocA4r2zqkO0up0mSbDuhTo90BLD7whdZlob9ssTEoMV2w6kvvrQ== X-Received: by 2002:a7b:ca47:: with SMTP id m7mr10995197wml.150.1558046609590; Thu, 16 May 2019 15:43:29 -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.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 May 2019 15:43:29 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 17 May 2019 00:30:17 +0200 Message-Id: <20190516223018.30827-34-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 33/37] avformat/matroskadec: Fix probing of unknown-length headers 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" matroska_probe did not support the case of an unknown-length EBML header at all; given that libavformat's Matroska muxer used to produce such files in the streaming case, support for them has been added. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 404e5005a7..edf21e5fe2 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1511,9 +1511,14 @@ static int matroska_probe(const AVProbeData *p) while (n < size) total = (total << 8) | p->buf[4 + n++]; - /* Does the probe data contain the whole header? */ - if (p->buf_size < 4 + size + total) - return 0; + if (total + 1 == 1ULL << (7 * size)){ + /* Unknown-length header - simply parse the whole buffer. */ + total = p->buf_size - 4 - size; + } else { + /* Does the probe data contain the whole header? */ + if (p->buf_size < 4 + size + total) + return 0; + } /* The header should contain a known document type. For now, * we don't parse the whole header but simply check for the