From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web12.10916.1572833447664873378 for ; Sun, 03 Nov 2019 18:10:47 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: liming.gao@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Nov 2019 18:10:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,265,1569308400"; d="scan'208";a="231904900" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga002.fm.intel.com with ESMTP; 03 Nov 2019 18:10:47 -0800 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 3 Nov 2019 18:10:47 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 3 Nov 2019 18:10:46 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.127]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.213]) with mapi id 14.03.0439.000; Mon, 4 Nov 2019 10:10:45 +0800 From: "Liming Gao" To: "devel@edk2.groups.io" , "Gao, Liming" , "Marvin.Haeuser@outlook.com" CC: "vit9696@protonmail.com" , "Kinney, Michael D" Subject: Re: [edk2-devel] [PATCH] MdePkg/UefiFileHandleLib: Fix potential NULL dereference Thread-Topic: [edk2-devel] [PATCH] MdePkg/UefiFileHandleLib: Fix potential NULL dereference Thread-Index: AQHVhz8WsmCsVfRgHEG2TcYkLyIZbqdkbCiQgBXvQjA= Date: Mon, 4 Nov 2019 02:10:44 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E53695B@SHSMSX104.ccr.corp.intel.com> References: <15CF8AEA297AE48F.24139@groups.io> In-Reply-To: <15CF8AEA297AE48F.24139@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Push @ 1009b59b6525c16724fe2684c344a6359af28b55 >-----Original Message----- >From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of >Liming Gao >Sent: Monday, October 21, 2019 11:12 AM >To: Marvin.Haeuser@outlook.com; devel@edk2.groups.io >Cc: vit9696@protonmail.com; Kinney, Michael D >Subject: Re: [edk2-devel] [PATCH] MdePkg/UefiFileHandleLib: Fix potential >NULL dereference > >Reviewed-by: Liming Gao > >>-----Original Message----- >>From: Marvin H=E4user [mailto:Marvin.Haeuser@outlook.com] >>Sent: Sunday, October 20, 2019 8:09 PM >>To: devel@edk2.groups.io >>Cc: vit9696@protonmail.com; Kinney, Michael D >>; Gao, Liming >>Subject: [PATCH] MdePkg/UefiFileHandleLib: Fix potential NULL dereferenc= e >> >>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 >>--- >> 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); >> >>-- >>2.23.0.windows.1 > > >