From patchwork Wed Sep 22 17:29:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 30459 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp753539iob; Wed, 22 Sep 2021 10:30:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwA295/tLYQKzmnTTRgVDdyVNzih1xErjlCmLC7SJLyitBtHpjbviMic0/WYcLBmmu+WQfz X-Received: by 2002:a17:906:dbf2:: with SMTP id yd18mr358656ejb.536.1632331806880; Wed, 22 Sep 2021 10:30:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632331806; cv=none; d=google.com; s=arc-20160816; b=TQ7My16oRUtqAL8+/St+XLZ53o2ODz6A2kxzbg2G2orbxDQjO3+5PV50YEZ8yWEJkI q31ELha0piMUkFGUnP84dK3TMcaUdqmhx8+MUT3f6lUlDZ+EmlErEDRU/novCbqCqpj5 pGqYRJ7jVkyBTiM0xOhWlRusIJ4vu4T8a+6ArElTTWvwhCixGF+fSpH+LJQe3tnHDbZE Y509zRplh45vB4VbjuCGHvv0A56V5Lp46x+nukyp78UVJF8pajCFT8Kty3vAONf0i66S tZaMVHHouT/Td0mhCVDEvOdPywrKipHYadTf5KN8DdWVL0DdTo8AD4fhsRxTsx0mGJZA eVMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=yvEBP4si4hLoild8Rj0enFgkVyfx0kNCaRZKFOEk5PY=; b=A0+CiNYvKj/DFUeQEAafJk7QSCPwSmLcsJ1LhohKddrUXNrgeghEpRjdFUkf0Bv7oa AWtQ8zWpgOWyaSALuh9vSYhKdfVrwO5OfW2qgneDprECqYFfM3SnfIR4P6HSJk8qrQhT D9gH2+FkZI07t8t7p2TbABYi1/uTi9BeJXfVRsGsu5JycEyP0u40MaDndtsdJM5CK2O5 RcFURM4D0uj2am6z7I1u037Wol5uIdqFiKASECSqpaH9mbdFVjS9ST0Q/atzSHpSUm+b RK/SNkgwKs/nAx0FaqZi9td6+LmHHdmMGIzESf2Rkt324rBSmEEFltr0aqC0EWbRyGoN 4Rew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id eb10si2234330edb.16.2021.09.22.10.30.06; Wed, 22 Sep 2021 10:30:06 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8422468ACF8; Wed, 22 Sep 2021 20:29:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D0C4868AB51 for ; Wed, 22 Sep 2021 20:29:27 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id BC0E0E5E81; Wed, 22 Sep 2021 19:29:27 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZwJToZTedDE6; Wed, 22 Sep 2021 19:29:26 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id F37DAE5E85; Wed, 22 Sep 2021 19:29:25 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 22 Sep 2021 19:29:14 +0200 Message-Id: <20210922172914.17914-4-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210922172914.17914-1-cus@passwd.hu> References: <20210922172914.17914-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] avformat/mpegts: fix max_packet_size in mpegts payload parsing X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: BBU45jLqcFjO The maximum allowed useful PES payload data was set to PES_packet_length, but it is in fact smaller by the length of the PES header. This changes how corrupt streams are packetized: - If PES header length is bigger than PES_packet_length then the PES packet payload will be handled as an unbound packet - PES packets with payload across multiple MPEGTS packets will always be splitted if with the next chunk of data the payload should exceed PES_packet_length, previously a PES_header_length amount of excess was allowed. Fixes ticket #9355. Signed-off-by: Marton Balint --- libavformat/mpegts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 7d2e7407c1..0029c4ca76 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1358,8 +1358,8 @@ skip: case MPEGTS_PAYLOAD: do { int max_packet_size = MAX_PES_PAYLOAD; - if (pes->PES_packet_length) - max_packet_size = pes->PES_packet_length; + if (pes->PES_packet_length && pes->PES_packet_length + PES_START_SIZE > pes->pes_header_size) + max_packet_size = pes->PES_packet_length + PES_START_SIZE - pes->pes_header_size; if (pes->data_index > 0 && pes->data_index + buf_size > max_packet_size) {