From nobody Tue Nov 26 16:21:32 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+49256+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+49256+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 1571585791260907.8524450929351; Sun, 20 Oct 2019 08:36:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id h2coYY1788612xf4FuWidHPQ; 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.48]) by mx.groups.io with SMTP id smtpd.web10.1514.1571573313801819695 for ; Sun, 20 Oct 2019 05:08:34 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EebMh99uVmWHVKEDq71umaLuTGcXURAB16kN/5wz4co/NI+uW2kIwuM4duVXxa95JMpMMN9zN8DdiWxUKpP9867qnH7K4qstq4zwQOusnUnLsmYslGB3tmnzXpqcYKfVh0vrGMufyAPf2K+qonPqt+d4Z6+PUp2N+FhrmExDyLa1ZQhjZRr6C9Y+EXG8Bx5nLV/t1+TpHj5tIjRh64tzVFvEh6YWkyd52g7PxXZyw12o/Fb9z1IalhFF0LhdPYgXwTzsI1gSBJgLS1o9DLxmf8tcf7OhWR0TGE9vOMC49Rrpap/ZP2jG1FrJhrZfqQHO+er2VlTLBZ3+3usmy3IeIQ== 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=3+70RWmReGEDQrm40Kk/WmMd2+4D3GL4FK/2YECwxco=; b=e3PG9eUKuM7ePdmowctvUnbqezZQ/MFtCa/Mx4qiRCS90E/hyXrE1DXcOe4sUCyeRnnaWo4UiPKW6ZLLP7WJ/asU4P/WZfT7u3uOa9LtTRbEibz/GfWU6DOQG1n7CyJXXc5qHB0T+L7ddHzHC6tc3tJSwOTMwjjPZ6clAe8zhklQerYQWAvNuFG6IllXgTeaigwn86Wcr6UhGduJswQUtV3VYWgod3ZW6uimsLElskWR/6Sboeb2hEvViV4dm+jXsZA8MpPuTLs/snuxoiA3wcyAzsE7AD239fHSSa3BW2zZbziq8SS/g265y0/OenMmPQBIgvsdEbnQK4fSL/dEkQ== 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 VE1EUR02HT192.eop-EUR02.prod.protection.outlook.com (10.152.12.245) 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:31 +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:31 +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:31 +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: Fix potential NULL dereference Thread-Topic: [PATCH] MdePkg/UefiFileHandleLib: Fix potential NULL dereference Thread-Index: AQHVhz8WsmCsVfRgHEG2TcYkLyIZbg== Date: Sun, 20 Oct 2019 12:08:31 +0000 Message-ID: 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:03DB81CBB37319999FAF408B6DBCC8E0D9EBE3E85AA2F5C3DDA29E1119B4A439;UpperCasedChecksum:7EE66EB21050FA1D922CE72FA1D2C8FDC9A24DD064DC304328BE32EAF0412663;SizeAsReceived:7625;Count:49 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [YpaHeOyoSAIxQ/p9UurZ3PrARQwoFPSM] x-microsoft-original-message-id: x-ms-publictraffictype: Email x-incomingheadercount: 49 x-eopattributedmessage: 0 x-ms-traffictypediagnostic: VE1EUR02HT192: x-ms-exchange-purlcount: 1 x-microsoft-antispam-message-info: vG2NW8OfgidV2fG2QG5Hd03M1dKz3nHfmOXhxOUo5uWpC3fgCcoO2tHhW03usv+Wj372rwoHHBsnlRCznHk/bf3qytRyDQx7jpTmeDlH4IDo6mH45hZZI5SEqDKj2omgP8sQs8TaUjxc7LdgdgjQgq7rO1L4zLIXvqfdZbI1kGvw0zchskcSVCLpk6hXyFsPGq72a0tCbtbx6vAZASb8XXrSmWdmLUAYmve555r7dGU= 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: e95f5f39-3f6d-4664-fbd7-08d7555638db X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Oct 2019 12:08:31.1168 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR02HT192 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: dye9vBRhL79Rpe3flsPHIDyIx1787277AA= 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=nTx1JLerpIbTnrQYKDtz1lLAqoCBlm20dduKwMMxDKc=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=VN69UKfwhFCPRX/8nwL+52+LIsE9Oa6wLQhhr3QXWDgSj2ZwhkZO5f6fxpD17kOFkp8 aRZxOszw3s8CO8qj81HLmui4VWF3EudPWEDNZxTCpFkRkXNREWm6r2cVButwgTNiFDyOl 4Le8fAxiu50/trbahOOlneT+6IfT8zj7Nuc= 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=3D2293 Move the NULL check in FileHandleGetInfo() to directly after the allocation to prevent potential NULL dereferences. Cc: Michael D Kinney Cc: Liming Gao Signed-off-by: Marvin Haeuser Reviewed-by: Liming Gao --- MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c | 28 +++++++++++-----= ---- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c b/MdePkg/= Library/UefiFileHandleLib/UefiFileHandleLib.c index 96913c5c02b8..5dc893833a46 100644 --- a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c +++ b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c @@ -68,19 +68,21 @@ FileHandleGetInfo ( // error is expected. getting size to allocate // FileInfo =3D AllocateZeroPool(FileInfoSize); - // - // now get the information - // - Status =3D FileHandle->GetInfo(FileHandle, - &gEfiFileInfoGuid, - &FileInfoSize, - FileInfo); - // - // if we got an error free the memory and return NULL - // - if (EFI_ERROR(Status) && (FileInfo !=3D NULL)) { - FreePool(FileInfo); - FileInfo =3D NULL; + if (FileInfo !=3D NULL) { + // + // now get the information + // + Status =3D FileHandle->GetInfo(FileHandle, + &gEfiFileInfoGuid, + &FileInfoSize, + FileInfo); + // + // if we got an error free the memory and return NULL + // + if (EFI_ERROR(Status)) { + FreePool(FileInfo); + FileInfo =3D NULL; + } } } return (FileInfo); --=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 (#49256): https://edk2.groups.io/g/devel/message/49256 Mute This Topic: https://groups.io/mt/35954827/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-