From: "Liming Gao" <liming.gao@intel.com>
To: "Gao, Zhichao" <zhichao.gao@intel.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>,
"Marvin.Haeuser@outlook.com" <Marvin.Haeuser@outlook.com>
Cc: "vit9696@protonmail.com" <vit9696@protonmail.com>,
"Kinney, Michael D" <michael.d.kinney@intel.com>
Subject: Re: [PATCH] MdePkg/UefiFileHandleLib: Tolerate more Root handle FileNames
Date: Mon, 4 Nov 2019 00:50:04 +0000 [thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E536709@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <3CE959C139B4C44DBEA1810E3AA6F9000B85A759@SHSMSX101.ccr.corp.intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
>-----Original Message-----
>From: Gao, Zhichao
>Sent: Thursday, October 24, 2019 10:52 AM
>To: devel@edk2.groups.io; Marvin.Haeuser@outlook.com
>Cc: vit9696@protonmail.com; Kinney, Michael D
><michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>
>Subject: RE: [PATCH] MdePkg/UefiFileHandleLib: Tolerate more Root handle
>FileNames
>
>This patch makes sense. The patch would not affect the original logic and
>figure out the failure if the root directory file name is '\\'.
>Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
>
>> -----Original Message-----
>> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
>> Marvin Häuser
>> Sent: Sunday, October 20, 2019 8:09 PM
>> To: devel@edk2.groups.io
>> Cc: vit9696@protonmail.com; Kinney, Michael D
>> <michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>
>> Subject: [edk2-devel] [PATCH] MdePkg/UefiFileHandleLib: Tolerate more
>> Root handle FileNames
>>
>> From: Marvin Haeuser <mhaeuser@outlook.de>
>>
>> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2295
>>
>> The current implementation of the FileHandleGetFileName() function
>> assumes that the Root directory always has the FileName '\0'.
>> However, the only requirement the UEFI specification defines is that a
>> prepended '\\' must be supported to access files and folders relative to the
>> Root directory.
>> This patch removes this assumption and supports constructing valid paths
>for
>> any value of FileName for the Root Directory.
>>
>> In practice, this fixes compatibility issues with File System drivers that report
>> '\\' as the FileName of the Root directory, which currently is both generating
>> an invalid path ("\\\\") and resulting in an EFI_NOT_FOUND result from the
>> CurrentHandle->Open() call.
>>
>> Cc: Michael D Kinney <michael.d.kinney@intel.com>
>> Cc: Liming Gao <liming.gao@intel.com>
>> Signed-off-by: Marvin Haeuser <mhaeuser@outlook.de>
>> ---
>> MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c | 25
>> ++++++++++++++------
>> 1 file changed, 18 insertions(+), 7 deletions(-)
>>
>> diff --git a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
>> b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
>> index 5dc893833a46..28e28e5f67d5 100644
>> --- a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
>> +++ b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
>> @@ -816,10 +816,25 @@ FileHandleGetFileName (
>> Status = EFI_OUT_OF_RESOURCES;
>> break;
>> } else {
>> + //
>> + // Prepare to move to the parent directory.
>> + // Also determine whether CurrentHandle refers to the Root directory.
>> + //
>> + Status = CurrentHandle->Open (CurrentHandle, &NextHigherHandle,
>> + L"..", EFI_FILE_MODE_READ, 0);
>> //
>> // We got info... do we have a name? if yes precede the current path
>> with it...
>> //
>> - if (StrLen (FileInfo->FileName) == 0) {
>> + if ((StrLen (FileInfo->FileName) == 0) || EFI_ERROR (Status)) {
>> + //
>> + // Both FileInfo->FileName being '\0' and EFI_ERROR() suggest that
>> + // CurrentHandle refers to the Root directory. As this loop ensures
>> + // FullFileName is starting with '\\' at all times, signal success
>> + // and exit the loop.
>> + // While FileInfo->FileName could theoretically be a value other than
>> + // '\0' or '\\', '\\' is guaranteed to be supported by the
>> + // specification and hence its value can safely be ignored.
>> + //
>> + Status = EFI_SUCCESS;
>> if (*FullFileName == NULL) {
>> ASSERT((*FullFileName == NULL && Size == 0) || (*FullFileName !=
>> NULL));
>> *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0); @@ -
>> 837,15 +852,11 @@ FileHandleGetFileName (
>> FreePool(FileInfo);
>> }
>> }
>> +
>> + FileHandleClose(CurrentHandle);
>> //
>> // Move to the parent directory
>> //
>> - Status = CurrentHandle->Open (CurrentHandle, &NextHigherHandle,
>> L"..", EFI_FILE_MODE_READ, 0);
>> - if (EFI_ERROR (Status)) {
>> - break;
>> - }
>> -
>> - FileHandleClose(CurrentHandle);
>> CurrentHandle = NextHigherHandle;
>> }
>> } else if (Status == EFI_NOT_FOUND) {
>> --
>> 2.23.0.windows.1
>>
>>
>>
next prev parent reply other threads:[~2019-11-04 0:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <aa5718fc4fdc610f03912cfcfd6fd8760d866117.1571572996.git.mhaeuser@outlook.de>
2019-10-20 12:08 ` [PATCH] ShellPkg/Ls: Consider UEFI timezone may not be set Marvin Häuser
2019-10-24 1:19 ` Gao, Zhichao
2019-10-20 12:08 ` [PATCH] MdePkg/UefiFileHandleLib: Tolerate more Root handle FileNames Marvin Häuser
2019-10-24 2:51 ` Gao, Zhichao
2019-11-04 0:50 ` Liming Gao [this message]
[not found] ` <15D3CF493CDD3994.15406@groups.io>
2019-11-04 2:07 ` [edk2-devel] " Liming Gao
2019-10-20 12:08 ` [PATCH] ShellPkg/Ls: Return empty content for all empty folders Marvin Häuser
2019-11-01 0:39 ` Gao, Zhichao
2019-10-20 12:08 ` [PATCH] UefiShellCommandLib: Default to first found UC for unsupported PlatformLang Marvin Häuser
2019-10-24 1:24 ` Gao, Zhichao
2019-11-05 3:03 ` Ni, Ray
2019-11-05 4:52 ` Gao, Zhichao
2019-11-05 6:41 ` Gao, Zhichao
2019-10-20 12:08 ` [PATCH] MdePkg/UefiDebugLibConOut: Pass the correct buffer size Marvin Häuser
2019-10-21 3:11 ` Liming Gao
[not found] ` <15CF8AE415F70486.7044@groups.io>
2019-11-04 2:11 ` [edk2-devel] " Liming Gao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14E536709@SHSMSX104.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox