From nobody Mon Feb 9 09:09:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97269+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97269+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1670856430; cv=none; d=zohomail.com; s=zohoarc; b=IDlFg2gprWaaQuoW7Lv69UfEGuEj1dUlvSDzHhsVv09PnjBBpJecMV6/qElhLcgzqeug9WQ61CI32s4jyX75klH1gvK5NJ11m581c1QjpoH+Zl81nxr2cy0aJuhKSmDjjTDx6WHTUAa5HiZbqwEgk+NVexMdMK5BulJwe3MbDRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670856430; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=2I35z+ORl6LnjhOs9TdexlbquQCnteQqpwkAtuahb80=; b=WAPDhe6y/FtJp/lLD7HExSBAhOJxH9TcvFMrtlDT5pIllurHiiAU8DZIKSz7xigBWS4cnipttX3DlQyxX9xSpfKiQLh4Qr1v3fdYUwBnnzgUlOnUlQySxBcYcm5m2KwRqnD32lIginzUBWT0Q2zhPAAfx/BNXPv+Zi/CC+Q051A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97269+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1670856430449916.7543515075535; Mon, 12 Dec 2022 06:47:10 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id ee4kYY1788612xzH0tq3cSKp; Mon, 12 Dec 2022 06:47:10 -0800 X-Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by mx.groups.io with SMTP id smtpd.web11.45003.1670856424392905373 for ; Mon, 12 Dec 2022 06:47:09 -0800 X-Received: by mail-lf1-f53.google.com with SMTP id p36so18957577lfa.12 for ; Mon, 12 Dec 2022 06:47:08 -0800 (PST) X-Gm-Message-State: pbT6aCRa31Wom27352hezuKDx1787277AA= X-Google-Smtp-Source: AA0mqf7VmnljBT6/PQ/TVow+xZa4r9agco5TdcGLgzsJ1eLGrb5nOr7y7s+MNV4UNRy4WvRUg+S57w== X-Received: by 2002:a05:6512:790:b0:4b5:9b8f:cc82 with SMTP id x16-20020a056512079000b004b59b8fcc82mr3758239lfr.0.1670856428223; Mon, 12 Dec 2022 06:47:08 -0800 (PST) X-Received: from localhost.localdomain ([77.221.215.144]) by smtp.gmail.com with ESMTPSA id t4-20020a056512030400b0049c29292250sm1643313lfp.149.2022.12.12.06.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 06:47:07 -0800 (PST) From: "Savva Mitrofanov" To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20H=C3=A4user?= , Pedro Falcato , Vitaly Cheptsov Subject: [edk2-devel] [edk2-platforms][PATCH v2 09/11] Ext4Pkg: Check that source file is directory in Ext4OpenInternal Date: Mon, 12 Dec 2022 20:46:52 +0600 Message-Id: <20221212144654.2650-10-savvamtr@gmail.com> In-Reply-To: <20221212144654.2650-1-savvamtr@gmail.com> References: <20221212144654.2650-1-savvamtr@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,savvamtr@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670856430; bh=e/iCVMvvjDdYPwKNed5Mvsv0Vkana1L6ANl124z99Lg=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=jHJ0sIzFq5U8mLS3swCejA+sCcXkieM24Vgj/JPyh7b/8v7IFPer9RJyEstFYTjX4uV PXsSlwQoMVkTrwg2wAt9jmsygx6oHkRa/eNFShm2euOvInKt74cZ4owYNxiYAJnXBTA8O 6QwQZiVa4y6R2JXKQciGohXPsP7SuxFoMQo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670856432411100037 Content-Type: text/plain; charset="utf-8" This check already present in the while loop below, but absent for cases when input file is nameless, so to handle assertion in Ext4ReadFile we need to add it at the top of function Cc: Marvin H=C3=A4user Cc: Pedro Falcato Cc: Vitaly Cheptsov Fixes: e55f0527dde48a5f139c1b8f35acc4e6b59dd794 Signed-off-by: Savva Mitrofanov --- Features/Ext4Pkg/Ext4Dxe/File.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Features/Ext4Pkg/Ext4Dxe/File.c b/Features/Ext4Pkg/Ext4Dxe/Fil= e.c index 04198a53bfc0..20a0194a5793 100644 --- a/Features/Ext4Pkg/Ext4Dxe/File.c +++ b/Features/Ext4Pkg/Ext4Dxe/File.c @@ -207,6 +207,11 @@ Ext4OpenInternal ( Level =3D 0; =20 DEBUG ((DEBUG_FS, "[ext4] Ext4OpenInternal %s\n", FileName)); + + if (!Ext4FileIsDir (Current)) { + return EFI_INVALID_PARAMETER; + } + // If the path starts with a backslash, we treat the root directory as t= he base directory if (FileName[0] =3D=3D L'\\') { FileName++; @@ -219,6 +224,10 @@ Ext4OpenInternal ( return EFI_ACCESS_DENIED; } =20 + if (!Ext4FileIsDir (Current)) { + return EFI_INVALID_PARAMETER; + } + // Discard leading path separators while (FileName[0] =3D=3D L'\\') { FileName++; @@ -242,10 +251,6 @@ Ext4OpenInternal ( =20 DEBUG ((DEBUG_FS, "[ext4] Opening %s\n", PathSegment)); =20 - if (!Ext4FileIsDir (Current)) { - return EFI_INVALID_PARAMETER; - } - if (!Ext4IsLastPathSegment (FileName)) { if (!Ext4DirCanLookup (Current)) { return EFI_ACCESS_DENIED; --=20 2.38.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97269): https://edk2.groups.io/g/devel/message/97269 Mute This Topic: https://groups.io/mt/95622337/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-