From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web11.10839.1572833263339622122 for ; Sun, 03 Nov 2019 18:07:43 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: liming.gao@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Nov 2019 18:07:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,265,1569308400"; d="scan'208";a="200366180" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga007.fm.intel.com with ESMTP; 03 Nov 2019 18:07:42 -0800 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 3 Nov 2019 18:07:41 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 3 Nov 2019 18:07:41 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.127]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.2]) with mapi id 14.03.0439.000; Mon, 4 Nov 2019 10:07:39 +0800 From: "Liming Gao" To: "devel@edk2.groups.io" , "Gao, Liming" , "Gao, Zhichao" , "Marvin.Haeuser@outlook.com" CC: "vit9696@protonmail.com" , "Kinney, Michael D" Subject: Re: [edk2-devel] [PATCH] MdePkg/UefiFileHandleLib: Tolerate more Root handle FileNames Thread-Topic: [edk2-devel] [PATCH] MdePkg/UefiFileHandleLib: Tolerate more Root handle FileNames Thread-Index: AQHVhz8Xr8i6u+dL8k2RjSKLZZeeZadpGp7ggBEqbsCAABWqsA== Date: Mon, 4 Nov 2019 02:07:39 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E53691C@SHSMSX104.ccr.corp.intel.com> References: <3CE959C139B4C44DBEA1810E3AA6F9000B85A759@SHSMSX101.ccr.corp.intel.com> <15D3CF493CDD3994.15406@groups.io> In-Reply-To: <15D3CF493CDD3994.15406@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Push @ 6407186db9505f101ece4e1571eceed69b9fbdbe >-----Original Message----- >From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of >Liming Gao >Sent: Monday, November 04, 2019 8:50 AM >To: Gao, Zhichao ; devel@edk2.groups.io; >Marvin.Haeuser@outlook.com >Cc: vit9696@protonmail.com; Kinney, Michael D >Subject: Re: [edk2-devel] [PATCH] MdePkg/UefiFileHandleLib: Tolerate more >Root handle FileNames > >Reviewed-by: Liming Gao > >>-----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 >>; Gao, Liming >>Subject: RE: [PATCH] MdePkg/UefiFileHandleLib: Tolerate more Root handle >>FileNames >> >>This patch makes sense. The patch would not affect the original logic an= d >>figure out the failure if the root directory file name is '\\'. >>Reviewed-by: Zhichao Gao >> >>> -----Original Message----- >>> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of >>> Marvin H=E4user >>> Sent: Sunday, October 20, 2019 8:09 PM >>> To: devel@edk2.groups.io >>> Cc: vit9696@protonmail.com; Kinney, Michael D >>> ; Gao, Liming >>> Subject: [edk2-devel] [PATCH] MdePkg/UefiFileHandleLib: Tolerate more >>> Root handle FileNames >>> >>> From: Marvin Haeuser >>> >>> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2295 >>> >>> 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 pat= hs >>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 >>> Cc: Liming Gao >>> Signed-off-by: Marvin Haeuser >>> --- >>> 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 =3D EFI_OUT_OF_RESOURCES; >>> break; >>> } else { >>> + // >>> + // Prepare to move to the parent directory. >>> + // Also determine whether CurrentHandle refers to the Root >directory. >>> + // >>> + Status =3D CurrentHandle->Open (CurrentHandle, &NextHigherHan= dle, >>> + L"..", EFI_FILE_MODE_READ, 0); >>> // >>> // We got info... do we have a name? if yes precede the curre= nt path >>> with it... >>> // >>> - if (StrLen (FileInfo->FileName) =3D=3D 0) { >>> + if ((StrLen (FileInfo->FileName) =3D=3D 0) || EFI_ERROR (Stat= us)) { >>> + // >>> + // Both FileInfo->FileName being '\0' and EFI_ERROR() sugge= st that >>> + // CurrentHandle refers to the Root directory. As this loo= p 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 =3D EFI_SUCCESS; >>> if (*FullFileName =3D=3D NULL) { >>> ASSERT((*FullFileName =3D=3D NULL && Size =3D=3D 0) || (*= FullFileName !=3D >>> NULL)); >>> *FullFileName =3D StrnCatGrowLeft(FullFileName, &Size, L"= \\", 0); @@ >- >>> 837,15 +852,11 @@ FileHandleGetFileName ( >>> FreePool(FileInfo); >>> } >>> } >>> + >>> + FileHandleClose(CurrentHandle); >>> // >>> // Move to the parent directory >>> // >>> - Status =3D CurrentHandle->Open (CurrentHandle, &NextHigherHandl= e, >>> L"..", EFI_FILE_MODE_READ, 0); >>> - if (EFI_ERROR (Status)) { >>> - break; >>> - } >>> - >>> - FileHandleClose(CurrentHandle); >>> CurrentHandle =3D NextHigherHandle; >>> } >>> } else if (Status =3D=3D EFI_NOT_FOUND) { >>> -- >>> 2.23.0.windows.1 >>> >>> >>> > > >