From patchwork Fri Jun 7 00:32:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 49634 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c209:0:b0:460:55fa:d5ed with SMTP id d9csp715715vqo; Thu, 6 Jun 2024 17:32:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVP2em9WPjWpcVj5ai68TiO651PdRCj9fzj5RNJzsbpToTOXGuaacbVZS981yOp28fNn51Cg9pwkUoN3+PgfTqHu8raaEnhnNkKuA== X-Google-Smtp-Source: AGHT+IGJVjy/w4mmJ2VYkPlp6ABaBg0ga7Jkkd17LjvzTsRsick0NsIZ2kJr/tjnLRu4A/bb0LK5 X-Received: by 2002:a50:cd9a:0:b0:57a:4a7d:5b9a with SMTP id 4fb4d7f45d1cf-57c50972f7cmr636883a12.26.1717720359178; Thu, 06 Jun 2024 17:32:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717720359; cv=none; d=google.com; s=arc-20160816; b=MlyaRgQ3lOS/9S4sc9a+mpCmw8q+pElinM723Kz+E8bgWCzr9BFgERFOGYMsEkdL15 C5ysr+UZ+Wc4VUzLiKEPeDYatGfmhiQFYRniZf3tx/4rQKl0/KeTgTjYfQhVvLoMoZah kCCFFLNMW526RUjTAcYFtfYbqYYwPDKb3zSC+/lEJMa5vmUu5BkPfv8gy87UXkT2LJcO TCdYMgzmZee58fBgtldJcu+ajiVaNbYcwunuwzIV3Sr+eBrKSZy1sbwp0jkIdtZjKWw3 Y1v0n1qsaD9BNStDV2O+Xv9hCBRj8Pne5/EVkZxGDL+vuN+LXbGS9zlonwuv29e+jJux Leng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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:dkim-signature:delivered-to; bh=iozNkihtIdb1PbIF9CvGKL+cvUXIKj64MUwxRV7g024=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=x7ev4F9IeDK1TOdvezUYS5E1+iU0L7rD0R/2Z/lPOiT6+6uTR2HH8kFyZYN7kjKSK1 RRvvNNo/B6HHlEAvEjxjU3mYBWDsu7BE5TccTctT3UBiQRMsn+Tlji9rHAIjfZaxSUyJ dN5i2tOzaWNenQNPwHOKnA2DH6C+IrR9e8iKixhGRBLORxxFEf0i7r0A5b21xmK9Y8FE F0+Ojg1fze0iYp9Bi4ZXwTS11vgajlmG6FLyXxzZLQEPXz7KNAQ33uJX11BbhG4sfDTQ AK44b4TbMkvC3MFAGneIFmSmUNB1VkAVO8c4oaakQsYbjcIJNwJOWt/VFgSCo1elOKu/ SPgQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=Sqk13b98; 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 4fb4d7f45d1cf-57aae2269casi1195111a12.349.2024.06.06.17.32.38; Thu, 06 Jun 2024 17:32:39 -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; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=Sqk13b98; 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 034E468D737; Fri, 7 Jun 2024 03:32:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BA38C68D6EF for ; Fri, 7 Jun 2024 03:32:18 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 017991BF204 for ; Fri, 7 Jun 2024 00:32:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1717720338; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iqZaf2iM6l5Om/iKlT5CPF7QSiJy6G0GnsIHfHnZi6s=; b=Sqk13b9870hj34BPREbhrfVc5EbZg1enX1HKSc8pMLMbWqCTI5/i9w2IHJDEg/K+XguNWx DBFt8EAJzgWy8GwcrCpDTqNMaecPoYlhAZIsR0Db9z8bRLJOe5LGZYvhec8ZpWMdhoinph aMyoBJMlmufhxHJeYwaDFh67SNa+wKeGdgk792skexsu6ztLII23iWWbiEiCuk8FMpnEbe ZKtbhSclSsO4eOHO4kusE7/9GUlbfz37NsE/3IFCb/MHuVrbgOPvoehbv8RsmPn36bi1dR tXTGsAZNcgHhlm36tmUnpqbjyZK2hxWrtsafM+0DoTeuMk98NOCrWpalpN4EIA== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 7 Jun 2024 02:32:12 +0200 Message-ID: <20240607003215.1723906-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240607003215.1723906-1-michael@niedermayer.cc> References: <20240607003215.1723906-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 2/5] avformat/mpeg: Check len in mpegps_probe() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 0gnOLyImbfjY Fixes: CID1473590 Untrusted loop bound Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- libavformat/mpeg.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 5556861e1c4..c3dff3e4ea2 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -76,6 +76,9 @@ static int mpegps_probe(const AVProbeData *p) int pes = endpes <= i && check_pes(p->buf + i, p->buf + p->buf_size); int pack = check_pack_header(p->buf + i); + if (len > INT_MAX - i) + break; + if (code == SYSTEM_HEADER_START_CODE) sys++; else if (code == PACK_START_CODE && pack)