From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.92.65.65; helo=eur01-he1-obe.outbound.protection.outlook.com; envelope-from=marvin.haeuser@outlook.com; receiver=edk2-devel@lists.01.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-oln040092065065.outbound.protection.outlook.com [40.92.65.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 58F9321130048 for ; Wed, 13 Jun 2018 13:27:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Om5fJ58hWLQRJui4+6tLvt12DMTZgCwd0LR0gxcNO9U=; b=H1DMTRQvbKQ3ZxPpkOBYWNsMsLD6axNfgXQ1b1dVp9W7ie3CuCIe88Bsv2DMk4QoMX9ifkRGHSyvHUlRvX902rsxdAsepGA4wRdQpacrLnvsw2JEqJX2tWYGqf1uO/O34ccUVO9ogkVdTQKZlKyYYGv0V1TOCYjab2mGKblxrEu7bbdiLIf94M+fNV1r3ab3d7cnCjwInGfh1RNqpw0BZoGYuc1T3ly7NMvRNI8AIeKLHl/aF8f6sFEkSqYAG2B5B9I5gJV9vdY+uN1y3ZI8INbnPhkTyBMSy9UEptVBPbR9t1MDtt8O/Uwbpl2Mc57ZKoRD6cx0i7VjfXJ1zGp8UQ== Received: from VE1EUR01FT039.eop-EUR01.prod.protection.outlook.com (10.152.2.51) by VE1EUR01HT095.eop-EUR01.prod.protection.outlook.com (10.152.3.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.863.11; Wed, 13 Jun 2018 20:27:41 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com (10.152.2.55) by VE1EUR01FT039.mail.protection.outlook.com (10.152.3.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.863.11 via Frontend Transport; Wed, 13 Jun 2018 20:27:41 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com ([fe80::b8fa:4bfe:9d63:439c]) by VI1PR0801MB1790.eurprd08.prod.outlook.com ([fe80::b8fa:4bfe:9d63:439c%2]) with mapi id 15.20.0841.019; Wed, 13 Jun 2018 20:27:41 +0000 From: =?iso-8859-1?Q?Marvin_H=E4user?= To: "edk2-devel@lists.01.org" , "michael.d.kinney@intel.com" , "liming.gao@intel.com" Thread-Topic: [PATCH v2] MdePkg/UefiFileHandleLib: Fix the Root directory determination. Thread-Index: AQHT7dxnT2a6E5yCNEyTecFsY1Idi6RezauA Date: Wed, 13 Jun 2018 20:27:41 +0000 Message-ID: References: <396ef0a31f51da8581a8100ed1c6a6358974038e.1526560735.git.Marvin.Haeuser@outlook.com> In-Reply-To: Accept-Language: de-DE, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:4D864182BCE10E200E942C75B6BCFC4298A4B008419F491B6B4D1FFD6F2B994B; UpperCasedChecksum:AF0B9604ABB84D76846C0E080CD5723F0A83D7DA678BCCD026079D382184192B; SizeAsReceived:7372; Count:45 x-tmn: [dLRx+Zq6tnEddZ9F2COnr/NpXXyFLK0A] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VE1EUR01HT095; 7:w7XDjgKZvrmbuQG2jCJQaEB9aQf/6ontlhiZ1tLuQ/3WZRDhJMLUrNTLZXe6tl2AXJc8Gt0EqSryNnLzcE+tKRmM9CN0IbBiwa2uSrH+hlm0ZCFAAeUYICsbcuUAr7Vd+xeHNZEsZ9S5ELfPvroWb7PApJtFeHdXM5WsBOcs5bZgI4TGakNDSLyT3DCai+VhYt6BSgdgpz+AB2yvbnnZL1wMAIVSX1QoV/K/ANUhkb0zpdGAJMzvpC+y7+A6lH2D x-incomingheadercount: 45 x-eopattributedmessage: 0 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1603101448)(1601125500)(1701031045); SRVR:VE1EUR01HT095; x-ms-traffictypediagnostic: VE1EUR01HT095: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(444000031); SRVR:VE1EUR01HT095; BCL:0; PCL:0; RULEID:; SRVR:VE1EUR01HT095; x-forefront-prvs: 07025866F6 x-forefront-antispam-report: SFV:NSPM; SFS:(7070007)(189003)(199004)(13464003)(966005)(2900100001)(11346002)(72206003)(446003)(229853002)(14454004)(6246003)(426003)(97736004)(305945005)(2501003)(5250100002)(87572001)(486006)(6436002)(33656002)(25786009)(20460500001)(74316002)(110136005)(476003)(106356001)(6346003)(8936002)(105586002)(68736007)(8676002)(7696005)(3660700001)(82202002)(81156014)(53546011)(102836004)(104016004)(26005)(76176011)(59450400001)(5660300001)(6306002)(55016002)(86362001)(3280700002)(2201001)(99286004); DIR:OUT; SFP:1901; SCL:1; SRVR:VE1EUR01HT095; H:VI1PR0801MB1790.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:; received-spf: None (protection.outlook.com: outlook.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Marvin.Haeuser@outlook.com; x-microsoft-antispam-message-info: m1gP6795eiAx6Yap7FOS7sRYogQ2Aaf7OKeMrQBBlFLT8bUe5eqyXi1oJWO1C1ztYI80aPeyngukcjX3nr2WGzYtgtkkrDiwd/2FWW8ohrzr0VQj23HtVqUro17wIlUEW1qMu7OY57+08DhdA/opO/WncoS6YZ+0Pnuc7gm5qZ4qI5zycpP+55K2957f0RPN MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: f6badccc-0a2c-4300-fa7d-08d5d16c1d2a X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-Network-Message-Id: f6badccc-0a2c-4300-fa7d-08d5d16c1d2a X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Jun 2018 20:27:41.7751 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR01HT095 Subject: Re: [PATCH v2] MdePkg/UefiFileHandleLib: Fix the Root directory determination. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 20:27:47 -0000 Content-Language: de-DE Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hey Liming and Mike, Sorry, but I have seen this and another patch to UefiFileHandleLib have not= been reviewed and/or merged yet. Is there anything wrong with the patches? Thanks, Marvin. > -----Original Message----- > From: edk2-devel On Behalf Of Marvin > H=E4user > Sent: Thursday, May 17, 2018 2:42 PM > To: edk2-devel@lists.01.org > Cc: michael.d.kinney@intel.com; liming.gao@intel.com > Subject: [edk2] [PATCH v2] MdePkg/UefiFileHandleLib: Fix the Root directo= ry > determination. >=20 > 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. >=20 > In praxis, this fixes compatibility issues with File System drivers that = report > '\\' as the FileName of the Root directory, which currently is both gener= ating > an invalid path ("\\\\") and resulting in an EFI_NOT_FOUND result from th= e > CurrentHandle->Open() call. >=20 > V2: > - Do not change the copyright date as requested. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Marvin Haeuser > --- > MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c | 27 > ++++++++++++++------ > 1 file changed, 19 insertions(+), 8 deletions(-) >=20 > diff --git a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c > b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c > index 57aad77bc135..251cbc55edb5 100644 > --- a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c > +++ b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c > @@ -820,10 +820,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 direc= tory. > + // > + Status =3D 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) =3D=3D 0) { > + if ((StrLen (FileInfo->FileName) =3D=3D 0) || EFI_ERROR (Status)= ) { > + // > + // Both FileInfo->FileName being '\0' and EFI_ERROR() suggest = that > + // CurrentHandle refers to the Root directory. As this loop e= nsures > + // FullFileName is starting with '\\' at all times, signal suc= cess > + // and exit the loop. > + // While FileInfo->FileName could theoretically be a value oth= er 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) || (*Ful= lFileName !=3D > NULL)); > *FullFileName =3D StrnCatGrowLeft(FullFileName, &Size, L"\\"= , 0); @@ - > 841,15 +856,11 @@ FileHandleGetFileName ( > FreePool(FileInfo); > } > } > - // > - // Move to the parent directory > - // > - Status =3D CurrentHandle->Open (CurrentHandle, &NextHigherHandle, > L"..", EFI_FILE_MODE_READ, 0); > - if (EFI_ERROR (Status)) { > - break; > - } >=20 > FileHandleClose(CurrentHandle); > + // > + // Move to the parent directory > + // > CurrentHandle =3D NextHigherHandle; > } > } else if (Status =3D=3D EFI_NOT_FOUND) { > -- > 2.17.0.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel