From nobody Tue May 7 12:01:08 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 1532118505062845.1323109241555; Fri, 20 Jul 2018 13:28:25 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9941E20D7ADF5; Fri, 20 Jul 2018 13:28:24 -0700 (PDT) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-oln040092071097.outbound.protection.outlook.com [40.92.71.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7267E20D7ADE7 for ; Fri, 20 Jul 2018 13:28:21 -0700 (PDT) Received: from AM5EUR03FT044.eop-EUR03.prod.protection.outlook.com (10.152.16.52) by AM5EUR03HT149.eop-EUR03.prod.protection.outlook.com (10.152.17.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.952.17; Fri, 20 Jul 2018 20:28:19 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com (10.152.16.59) by AM5EUR03FT044.mail.protection.outlook.com (10.152.17.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.952.17 via Frontend Transport; Fri, 20 Jul 2018 20:28:19 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com ([fe80::7532:4dc6:e9f7:4765]) by VI1PR0801MB1790.eurprd08.prod.outlook.com ([fe80::7532:4dc6:e9f7:4765%2]) with mapi id 15.20.0973.018; Fri, 20 Jul 2018 20:28:19 +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.71.97; helo=eur03-db5-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=NwlwYAx2CrBqrlQ/69x3AIok3Xtd1Uk05+qBKpYNAhc=; b=Z/UXxCm/8DgO8y0yghdqYggdgm3QEhhgA8HxArL8kPOmRi31loqxfd4KRNoY1W9LmTspE3uQu1SIxomn3gm42dhUCisxtDzdEsnZ5ZdJB6JU5Rw/d1PqopEZ+G9Oy2Hi3To1nOZyRkh+vpVii4v/X24LL2ZQVNsFt0J+ptDOI0abWt8E4RuCZIHA1DEFDgEQbCm9EyvAMo0O3ILEwqjq9x0SKkoMEmVCpVsrNQV7QZIALWJViUtipYFgj7VT6g714RniTEUt/gE577/gLeAhKZR459vNEGYrDjrSNp2bmezHPZQyhQanWO6SxzkE637ITvsJ5JRZAIBzbr6OtuWghg== From: =?iso-8859-1?Q?Marvin_H=E4user?= To: "edk2-devel@lists.01.org" Thread-Topic: [PATCH v3] MdePkg/UefiFileHandleLib: Fix the Root directory determination. Thread-Index: AQHUIGgyUb/OsBOTBk2uyyZi5c1mWQ== Date: Fri, 20 Jul 2018 20:28:19 +0000 Message-ID: Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0226.eurprd05.prod.outlook.com (2603:10a6:3:fa::26) To VI1PR0801MB1790.eurprd08.prod.outlook.com (2603:10a6:800:5b::15) x-incomingtopheadermarker: OriginalChecksum:E9E756130470E4D7AA6DDFFFE2B941E8F638B1790BD93F57D4ABE57943823B6D; UpperCasedChecksum:8DD38100FC5D25A9665C77581F48AD88C0A1F81F2F9979C8AD33C6DDD6B216F3; SizeAsReceived:7542; Count:48 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [ngHFD/cRSlI3YRiH2VOdpvO0Yeaj5FeQ] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM5EUR03HT149; 7:SIVcWAGyQg0nLxfnNo5ATlM/GuwyNTd60sOcEMBQX+hmSzSRQ/HvJpmQtbdoLgPlDg2nWimd+Uuqu4hIlbRq7Crzr0iSVfQ7ibNsYvA5OJIkb7v5Yvs/xVMNanwtHtfIpcxuR3OfRi/byVp07pMLJR9vOr2/PDjgghX3BjkyyLsEA7+LtQFLnQttbAER/dRkgQzQvs+GXoatlRZiVBzYJS6F+RTKs8BH/KpojXB2wAcsIe61n7QsVbmMZ8VGmO1z x-incomingheadercount: 48 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:AM5EUR03HT149; x-ms-traffictypediagnostic: AM5EUR03HT149: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(82015058); SRVR:AM5EUR03HT149; BCL:0; PCL:0; RULEID:; SRVR:AM5EUR03HT149; x-forefront-prvs: 073966E86B x-forefront-antispam-report: SFV:NSPM; SFS:(7070007)(189003)(199004)(104016004)(72206003)(68736007)(54906003)(87572001)(99286004)(2501003)(14454004)(5660300001)(8936002)(81156014)(6916009)(8676002)(6436002)(5250100002)(5640700003)(6346003)(55016002)(33656002)(476003)(74316002)(2351001)(2900100001)(25786009)(82202002)(426003)(486006)(105586002)(4326008)(7696005)(14444005)(106356001)(386003)(102836004)(256004)(56003)(26005)(97736004)(86362001)(20460500001)(305945005); DIR:OUT; SFP:1901; SCL:1; SRVR:AM5EUR03HT149; 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: IAd0uiOiHrlYMHK08F+FJq9GbppkZQ0ORP9BosaEaa/PGfYCnojWsS8CSz+VLBOpLdyddF++H7Q3sUXLuUhTsEyKld7+hAyOtyvgK/L+Xy2DR0FLZyzB44c36J3M6hk95XqQVn5czv9M+39gpY+T4pD+/WVpwmMqNaiFmPtH0nXAIiL2HRvICf7HCcjYGEsUa0NhbL2LlYF+R/k0s/poQndPa6NH4ORtB3qHcm0/eCo= MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-Network-Message-Id: f0dc32c2-164b-4ad6-bd7f-08d5ee7f54b9 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jul 2018 20:28:19.9064 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5EUR03HT149 Subject: [edk2] [PATCH v3] MdePkg/UefiFileHandleLib: Fix the Root directory determination. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "michael.d.kinney@intel.com" , "ruiyu.ni@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 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. V2: - Do not change the copyright date as requested. V3: - Simplify the root check to not check the length of FileName. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marvin Haeuser --- MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c | 26 ++++++++++++++--= ---- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c b/MdePkg/= Library/UefiFileHandleLib/UefiFileHandleLib.c index a768c3e23ae5..0a316231f984 100644 --- a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c +++ b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c @@ -820,10 +820,24 @@ 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 (EFI_ERROR (Status)) { + // + // EFI_ERROR() suggests 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 =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 +855,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.18.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel