From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: ray.ni@intel.com) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by groups.io with SMTP; Wed, 04 Sep 2019 11:20:42 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 11:20:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,467,1559545200"; d="scan'208";a="190249373" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by FMSMGA003.fm.intel.com with ESMTP; 04 Sep 2019 11:20:41 -0700 Received: from fmsmsx151.amr.corp.intel.com (10.18.125.4) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 4 Sep 2019 11:20:41 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX151.amr.corp.intel.com (10.18.125.4) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 4 Sep 2019 11:18:26 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.32]) by shsmsx102.ccr.corp.intel.com ([169.254.2.113]) with mapi id 14.03.0439.000; Thu, 5 Sep 2019 02:18:24 +0800 From: "Ni, Ray" To: "Gao, Zhichao" , "devel@edk2.groups.io" CC: "Carsey, Jaben" , Andrew Fish Subject: Re: [edk2-devel] [PATCH V2] ShellPkg/UefiHandleParsingLib: Fix incorrect reallocate pool Thread-Topic: [edk2-devel] [PATCH V2] ShellPkg/UefiHandleParsingLib: Fix incorrect reallocate pool Thread-Index: AQHVYWuWqrJ7sXuA70WPdATE9pKGHKcb10Ug Date: Wed, 4 Sep 2019 18:18:24 +0000 Deferred-Delivery: Wed, 4 Sep 2019 18:18:00 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C2C1FA1@SHSMSX104.ccr.corp.intel.com> References: <20190722065756.18856-1-zhichao.gao@intel.com> <15B3A870E6EA7BDB.7925@groups.io> <3CE959C139B4C44DBEA1810E3AA6F9000B833EE7@SHSMSX101.ccr.corp.intel.com> In-Reply-To: <3CE959C139B4C44DBEA1810E3AA6F9000B833EE7@SHSMSX101.ccr.corp.intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYWJmOWQ0MzMtNzdhYy00NzhkLTk1M2UtY2NhOWE5NmQ5YWFiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiYWJHUkVNMyt0TVZYbDFFUXpGNWlhU0RMK25MbW55N2hcL3Q1OWE0cWtPUDVQQW14cGJzSms5SUdYb2VyaW5ZVFgifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: ray.ni@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni > -----Original Message----- > From: Gao, Zhichao > Sent: Monday, September 2, 2019 1:51 AM > To: devel@edk2.groups.io; Gao, Zhichao > Cc: Carsey, Jaben ; Ni, Ray ; = Andrew Fish > Subject: RE: [edk2-devel] [PATCH V2] ShellPkg/UefiHandleParsingLib: Fix = incorrect reallocate pool >=20 > Hi Ray, >=20 > Please help to review this patch. >=20 > Thanks, > Zhichao >=20 > > -----Original Message----- > > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > > Gao, Zhichao > > Sent: Monday, July 22, 2019 2:58 PM > > To: devel@edk2.groups.io > > Cc: Carsey, Jaben ; Ni, Ray = ; > > Andrew Fish > > Subject: [edk2-devel] [PATCH V2] ShellPkg/UefiHandleParsingLib: Fix > > incorrect reallocate pool > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1965 > > > > For function InsertNewGuidNameMapping, it rellocate the mGuidList with > > new size > > "mGuidListCount+1 * sizeof(GUID_INFO_BLOCK)". That isn't its purpose a= nd > > would cause a overflow operation in "mGuidList[mGuidListCount - 1].xxx= =3D > > xxx". Its purpose is to increase 1 block size of mGuidList. Change it = to > > "(mGuidListCount + 1) * sizeof (GUID_INFO_BLOCK)". > > > > Adjust the coding style of this function. > > > > Cc: Jaben Carsey > > Cc: Ray Ni > > Cc: Andrew Fish > > Signed-off-by: Zhichao Gao > > --- > > > > V2: > > Update the copyright. > > > > .../UefiHandleParsingLib/UefiHandleParsingLib.c | 14 +++++++++----= - > > 1 file changed, 9 insertions(+), 5 deletions(-) > > > > diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLi= b.c > > b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c > > index f179c41092..43c19b9a91 100644 > > --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c > > +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c > > @@ -1,7 +1,7 @@ > > /** @file > > Provides interface to advanced shell functionality for parsing both= handle > > and protocol database. > > > > - Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<= BR> > > + Copyright (c) 2010 - 2019, Intel Corporation. All rights > > + reserved.
> > (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P. > > (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP > > SPDX-License-Identifier: BSD-2-Clause-Patent @@ -2462,17 +2462,21 @= @ > > InsertNewGuidNameMapping( > > IN CONST DUMP_PROTOCOL_INFO DumpFunc OPTIONAL > > ) > > { > > - ASSERT(Guid !=3D NULL); > > - ASSERT(NameID !=3D 0); > > + ASSERT (Guid !=3D NULL); > > + ASSERT (NameID !=3D 0); > > > > - mGuidList =3D ReallocatePool(mGuidListCount * sizeof(GUID_INFO_BLOC= K), > > mGuidListCount+1 * sizeof(GUID_INFO_BLOCK), mGuidList); > > + mGuidList =3D ReallocatePool ( > > + mGuidListCount * sizeof (GUID_INFO_BLOCK), > > + (mGuidListCount + 1) * sizeof (GUID_INFO_BLOCK), > > + mGuidList > > + ); > > if (mGuidList =3D=3D NULL) { > > mGuidListCount =3D 0; > > return (EFI_OUT_OF_RESOURCES); > > } > > mGuidListCount++; > > > > - mGuidList[mGuidListCount - 1].GuidId =3D > > AllocateCopyPool(sizeof(EFI_GUID), Guid); > > + mGuidList[mGuidListCount - 1].GuidId =3D AllocateCopyPool (sizeof > > (EFI_GUID), Guid); > > mGuidList[mGuidListCount - 1].StringId =3D NameID; > > mGuidList[mGuidListCount - 1].DumpInfo =3D DumpFunc; > > > > -- > > 2.21.0.windows.1 > > > > > >=20