From nobody Sat May 4 12:23:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=outlook.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1526560909102846.9821097529837; Thu, 17 May 2018 05:41:49 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D7288207E36D1; Thu, 17 May 2018 05:41:46 -0700 (PDT) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-oln040092066109.outbound.protection.outlook.com [40.92.66.109]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 96F73207E36B6 for ; Thu, 17 May 2018 05:41:43 -0700 (PDT) Received: from HE1EUR01FT049.eop-EUR01.prod.protection.outlook.com (10.152.0.53) by HE1EUR01HT036.eop-EUR01.prod.protection.outlook.com (10.152.0.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.776.10; Thu, 17 May 2018 12:41:41 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com (10.152.0.56) by HE1EUR01FT049.mail.protection.outlook.com (10.152.0.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.776.10 via Frontend Transport; Thu, 17 May 2018 12:41:41 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com ([fe80::7010:5d5e:8dcf:d92e]) by VI1PR0801MB1790.eurprd08.prod.outlook.com ([fe80::7010:5d5e:8dcf:d92e%17]) with mapi id 15.20.0776.010; Thu, 17 May 2018 12:41:40 +0000 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.92.66.109; helo=eur01-ve1-obe.outbound.protection.outlook.com; envelope-from=marvin.haeuser@outlook.com; receiver=edk2-devel@lists.01.org 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=93WJSykx+4WaqjTI7KwG1WHlj/jId3GVLQJYgSFawDM=; b=dyVfdDG94zCzByc10SgGElq/R1F8/02meclw+2S6XuqrRlyNANS+k4qIk7MKn8nR91500VVWRzSL9iWrJxsz/ixy86sOrKcclpOqxDgqbzBC809WkbTkWshBN11zkX6bueVzX4qadsMDIsEZC+bSoXl2G0lR3e5kU+LSTuZvq9W4awuYSKSEa1W08fnFvxjm7jjZNET6M4jPL5ahxqEa/k13YT/xhnXR1wgvOMidYnbYo3nv27ddfQQaRhyXot+O86VfkDdf1cE227Ypv3c7t1qp4nlHVEgPrj+0YKwi7GpOGhxzxSbEichKlx4phzj0OypqzN28yslyIrVHF1+SVg== From: =?iso-8859-1?Q?Marvin_H=E4user?= To: "edk2-devel@lists.01.org" Thread-Topic: [PATCH v2] MdePkg/UefiFileHandleLib: Fix the Root directory determination. Thread-Index: AQHT7dxnT2a6E5yCNEyTecFsY1Idiw== Date: Thu, 17 May 2018 12:41:40 +0000 Message-ID: References: <396ef0a31f51da8581a8100ed1c6a6358974038e.1526560735.git.Marvin.Haeuser@outlook.com> In-Reply-To: <396ef0a31f51da8581a8100ed1c6a6358974038e.1526560735.git.Marvin.Haeuser@outlook.com> Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM0PR0102CA0046.eurprd01.prod.exchangelabs.com (2603:10a6:208::23) To VI1PR0801MB1790.eurprd08.prod.outlook.com (2603:10a6:800:5b::15) x-incomingtopheadermarker: OriginalChecksum:9A857C79D89D7EB15135D381CFBC8A97C3696A3C8DED3367CCE3D419079D4DA1; UpperCasedChecksum:9F77E96B1F52F4BAD9937F4AD59E61B76B314F0FD66EF2AC8096AD6367F06E3C; SizeAsReceived:7711; Count:50 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [k9p8BkOzCRYza/guytYjHFpecny74HZa] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; HE1EUR01HT036; 7:zR4Ac3JVIjjDjbAeFf591o7q6MPGrrOFY/4hygvfm5I+WJ3CZ3DJuZAxr09Tpqm/akvBpbZpE8IwkEM9aV+WD9+uSoPRMYhYyXlInEyxaj/sYkFeZg4yRoQeTyh1rHS0/ZFpYiYntFA2s8LFzGnasTIerzsoI+O2Pg7v/77BvqasL55UaJdUxvY27LP9KtwqoL5HrMXXoW18jKzJto4sgzwRNzNPkX95mIKMdLjHK7ExZOyeFC5KLFWTH0sNO8hw x-incomingheadercount: 50 x-eopattributedmessage: 0 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1601125466)(1603101448)(1701031045); SRVR:HE1EUR01HT036; x-ms-traffictypediagnostic: HE1EUR01HT036: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(444000031); SRVR:HE1EUR01HT036; BCL:0; PCL:0; RULEID:; SRVR:HE1EUR01HT036; x-forefront-prvs: 067553F396 x-forefront-antispam-report: SFV:NSPM; SFS:(7070007)(199004)(189003)(6346003)(2501003)(5250100002)(26005)(446003)(11346002)(59450400001)(476003)(486006)(102836004)(104016004)(76176011)(426003)(7696005)(25786009)(68736007)(99286004)(14454004)(86362001)(106356001)(105586002)(5660300001)(5640700003)(72206003)(386003)(55016002)(74316002)(87572001)(82202002)(2900100001)(6436002)(3660700001)(3280700002)(8676002)(2351001)(81156014)(20460500001)(97736004)(305945005)(6916009)(33656002)(54906003)(4326008)(8936002); DIR:OUT; SFP:1901; SCL:1; SRVR:HE1EUR01HT036; H:VI1PR0801MB1790.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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: nlz2sgnQepixA2t/I6By1GVh36ojGj7eGzBLUJQknUc2Wl3MvbsayQwWezbwteLiapJ06juw0SNLfzSM2kLPa4y9X7YHm95UBdPFWceclvmBk3BoZWJRKI5TYCpGoyW/89HrCD8ZSzjqu4be/TwJdAVxNFmIYij16yqPnbCrpPA01kw/WSmuTnafpqO4wKfY MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 53fe069b-adff-4d22-1c5a-08d5bbf38989 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-Network-Message-Id: 53fe069b-adff-4d22-1c5a-08d5bbf38989 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-originalarrivaltime: 17 May 2018 12:41:40.8579 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR01HT036 Subject: [edk2] [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: , Cc: "michael.d.kinney@intel.com" , "liming.gao@intel.com" Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 praxis, 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. V2: - Do not change the copyright date as requested. 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(-) 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 directo= ry. + // + 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 pa= th 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 th= at + // CurrentHandle refers to the Root directory. As this loop ens= ures + // FullFileName is starting with '\\' at all times, signal succe= ss + // 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) || (*FullF= ileName !=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) { --=20 2.17.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel