From nobody Sat May 4 10:55:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+49258+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+49258+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=outlook.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1571585791257970.658195084736; Sun, 20 Oct 2019 08:36:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id jTyVYY1788612xtTXVt4B0DV; Sun, 20 Oct 2019 08:36:30 -0700 X-Received: from EUR02-VE1-obe.outbound.protection.outlook.com (EUR02-VE1-obe.outbound.protection.outlook.com [40.92.69.41]) by mx.groups.io with SMTP id smtpd.web12.1504.1571573315251344544 for ; Sun, 20 Oct 2019 05:08:35 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lkvEYSzk7SU1o1jWtFsoMn2rwCbw7MrW9Vv0SIihp/9kMfesmJ/U7Wm5TDWYUJMdvHZ8AsXAU0eAT40RMr11/uugdah686tN8B0hI/jZPArflnkakAPh2StnpooPvd5dL/Me+mBaPouD+IJJMYNnXBvY+a7TIRVkfFSI2ZBeyRipO8vysbkyvIdFGxnY2bgCCLVLVcSvBudJaJbh1YZTHiOKVVQVKBKyi2qrS6pnDev7fkxYcHHst2X8KLeagS0fQ8zI8eoClJLX4J2JXDt/qmgW3Ra+6bbywZpoN8vKc/M7+EPpncJIRqWEph+IZzzyafPT2b0B88hVyjDvqUUqDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SCNvtkqACwvkdjk5ndvnnKJJ9XAf0TdgKReEHiZ0Oc0=; b=iO02bz+atd7g7StFQVIYqsj/fuKmdl2vMnpN8VBnZsFH6k/fZerk22xlgvOL7yNe+HqN4b4LmkLEAAzQ/UanSQrz7s2isQuEFr6A1kZQIbKtY+Srahczugan+3Nj2D8QmA8Akpk8Hebj2hhRJshGWJEr/aiQZTUe2O7sDveP9rqATPQLj9imT0bsGJUQvt8SCPJpAIKLaGByLY4r0Zyj9WzsJF+aONXncx14xivJb2trqOvWp+GXNKiQEO7lpuQ8i0+nUArulz7HXhsVlA+OdyxD4H6L2qCY5xf1qVWIClotauNPn6SYJ72HPjdssgwhHmqWPZ4mZcwT4Y43Zb/9rQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none X-Received: from VE1EUR02FT003.eop-EUR02.prod.protection.outlook.com (10.152.12.55) by VE1EUR02HT150.eop-EUR02.prod.protection.outlook.com (10.152.13.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.14; Sun, 20 Oct 2019 12:08:33 +0000 X-Received: from DB7PR07MB4917.eurprd07.prod.outlook.com (10.152.12.58) by VE1EUR02FT003.mail.protection.outlook.com (10.152.12.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.14 via Frontend Transport; Sun, 20 Oct 2019 12:08:32 +0000 X-Received: from DB7PR07MB4917.eurprd07.prod.outlook.com ([fe80::1b8:f59a:96de:82ef]) by DB7PR07MB4917.eurprd07.prod.outlook.com ([fe80::1b8:f59a:96de:82ef%3]) with mapi id 15.20.2367.021; Sun, 20 Oct 2019 12:08:32 +0000 From: =?iso-8859-1?Q?Marvin_H=E4user?= To: "devel@edk2.groups.io" CC: "vit9696@protonmail.com" , Michael D Kinney , Liming Gao Subject: [edk2-devel] [PATCH] MdePkg/UefiFileHandleLib: Tolerate more Root handle FileNames Thread-Topic: [PATCH] MdePkg/UefiFileHandleLib: Tolerate more Root handle FileNames Thread-Index: AQHVhz8Xr8i6u+dL8k2RjSKLZZeeZQ== Date: Sun, 20 Oct 2019 12:08:32 +0000 Message-ID: References: In-Reply-To: Accept-Language: de-DE, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM0PR01CA0052.eurprd01.prod.exchangelabs.com (2603:10a6:208:e6::29) To DB7PR07MB4917.eurprd07.prod.outlook.com (2603:10a6:10:5f::30) x-incomingtopheadermarker: OriginalChecksum:732F534A713E11E224E24BD86133933743F1D7178AB22C576534FF68000A3BDE;UpperCasedChecksum:AAE94BADB8E0DA03CAC53D01A344553B4297749FE9AB27CF92D15B1529C02DC3;SizeAsReceived:7795;Count:51 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [0FW4TW5X7bbXldF3SXu7I1MQ2dgxxGSN] x-microsoft-original-message-id: x-ms-publictraffictype: Email x-incomingheadercount: 51 x-eopattributedmessage: 0 x-ms-traffictypediagnostic: VE1EUR02HT150: x-ms-exchange-purlcount: 1 x-microsoft-antispam-message-info: blXt7PgEn1fGacoMbsv4jQwbbWx6vOBXu6382memqSoa/LZxW4xfG6BXxqBCyqnaC+Da0iXqGhabxSRCg13/aWaMgQ7zs3ODVo4TbUDYAicoEjfNianLAfcVwm+454K3TVmSUcfWqtNBGKtIa5ztGnpN//RA3TEOG89UMR9b691cCg2J/MQzJYgY5xVRobafzoqZ8DxhMJlEdHp2Iiw9/d92vrRo+AIqLL0vzyJ6f9Q= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 786c0dbb-244b-4de3-7015-08d7555639f5 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Oct 2019 12:08:32.8321 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR02HT150 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,Marvin.Haeuser@outlook.com X-Gm-Message-State: kggEZPmdAs6VQN2sDwsYsx38x1787277AA= Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1571585790; bh=i5ywhJNw80zy5FGGPIMQ1yvODhz+4gnZeByNWTwrmYI=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=r+GJWg3GXqUr4EV88eBjWy3G34JMsyJA1wVeVqZCVGLfrUNxdjXPQXZ0HULWA9ZtR9I xXHNWqQC3y8S7Wtp5Co0MSUYQ0ZvpRDQ0fw+m5Eex0gHkF2X1GpgcAeyvYahxf329GS4n e1lAdm/RkzLCcFjVC+J6HAUCR9Xc4sBNCI8= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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 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 Cc: Liming Gao Signed-off-by: Marvin Haeuser Reviewed-by: Liming Gao Reviewed-by: Zhichao Gao --- 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 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); @@ -837,15 +852,11 @@ FileHandleGetFileName ( FreePool(FileInfo); } } + + FileHandleClose(CurrentHandle); // // Move to the parent directory // - Status =3D CurrentHandle->Open (CurrentHandle, &NextHigherHandle, L"= ..", EFI_FILE_MODE_READ, 0); - if (EFI_ERROR (Status)) { - break; - } - - FileHandleClose(CurrentHandle); CurrentHandle =3D NextHigherHandle; } } else if (Status =3D=3D EFI_NOT_FOUND) { --=20 2.23.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#49258): https://edk2.groups.io/g/devel/message/49258 Mute This Topic: https://groups.io/mt/35954830/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-