From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by mx.groups.io with SMTP id smtpd.web11.103343.1674830010811226702 for ; Fri, 27 Jan 2023 06:33:31 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@posteo.de header.s=2017 header.b=HDMWN8E4; spf=pass (domain: posteo.de, ip: 185.67.36.65, mailfrom: mhaeuser@posteo.de) Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 23A5C2405DE for ; Fri, 27 Jan 2023 15:33:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1674830009; bh=ytiYdt2bp85fNLigTRaQXuVZszs3ZCjuu1Mip4J3a0c=; h=Subject:From:Date:Cc:To:From; b=HDMWN8E4BAi3ojg5PPHLnK49+HG58KGz0PgVSU1DxQYAI+g7gxqFU4eOpv5Gp12l0 LhFvTVd/U+/3p5mctNWh9AiZz9cRKzo2BBAmj0CJWs/UDEeNaiUeovkCaWCgnCj3jg namDGxJpln7nkeYgZ4YRe8k1fWgQ9cHJVFZJ2mDrslqBUJq3xZhYGbeBSJpqssw7nn rw5BTlK1Uc4wucUNXXovu5vpq0u7cw5M9ejHQw8f5EpHETe4xAdPMBwPYZCNJIbiAc fZRtBCNZcNEKRccjRkfcq7LWJO/2C7hEbj0PBOJrIrd6Rjd0OHrg3fMuxGwBWu9XCU XCelaLMf3DEpw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4P3KnM5p8hz9rxS; Fri, 27 Jan 2023 15:33:27 +0100 (CET) Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.400.51.1.1\)) Subject: Re: [edk2-platforms][PATCH v3 07/11] Ext4Pkg: Check that source file is directory in Ext4OpenInternal From: =?UTF-8?B?TWFydmluIEjDpHVzZXI=?= In-Reply-To: Date: Fri, 27 Jan 2023 14:33:17 +0000 Cc: Savva Mitrofanov , edk2-devel-groups-io , Vitaly Cheptsov Message-Id: References: <20230127092945.94389-1-savvamtr@gmail.com> <20230127092945.94389-8-savvamtr@gmail.com> To: Pedro Falcato Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Reviewed-by: Marvin H=C3=A4user > On 27. Jan 2023, at 15:26, Pedro Falcato = wrote: >=20 > On Fri, Jan 27, 2023 at 9:29 AM Savva Mitrofanov = wrote: >>=20 >> 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 >>=20 >> Cc: Marvin H=C3=A4user >> Cc: Pedro Falcato >> Cc: Vitaly Cheptsov >> Fixes: d9ceedca6c8f ("Ext4Pkg: Add Ext4Dxe driver.") >> Signed-off-by: Savva Mitrofanov >> --- >> Features/Ext4Pkg/Ext4Dxe/File.c | 13 +++++++++---- >> 1 file changed, 9 insertions(+), 4 deletions(-) >>=20 >> diff --git a/Features/Ext4Pkg/Ext4Dxe/File.c = b/Features/Ext4Pkg/Ext4Dxe/File.c >> index 8dfe324255f4..9dde4a5d1a2d 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 the 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; >> -- >> 2.39.0 >>=20 >=20 > Reviewed-by: Pedro Falcato >=20 > --=20 > Pedro