From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.2701.1574916602847620428 for ; Wed, 27 Nov 2019 20:50:03 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: ray.ni@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Nov 2019 20:50:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,252,1571727600"; d="scan'208";a="217521150" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga001.fm.intel.com with ESMTP; 27 Nov 2019 20:50:01 -0800 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 27 Nov 2019 20:50:01 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 27 Nov 2019 20:50:01 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.127]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.60]) with mapi id 14.03.0439.000; Thu, 28 Nov 2019 12:49:59 +0800 From: "Ni, Ray" To: "Gao, Zhichao" , "devel@edk2.groups.io" CC: "Carsey, Jaben" , Andrew Fish Subject: Re: [edk2-devel] [PATCH] ShellPkg/UefiHandleParsingLib: Fix error allocate pool Thread-Topic: [edk2-devel] [PATCH] ShellPkg/UefiHandleParsingLib: Fix error allocate pool Thread-Index: AQHVOt9DAcMMQBgxGECP4ja/HlhoMKegr2xggAAo/RA= Date: Thu, 28 Nov 2019 04:49:59 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C37143D@SHSMSX104.ccr.corp.intel.com> References: <20190715073007.25732-1-zhichao.gao@intel.com> <15B1842A1397F2E7.11928@groups.io> <3CE959C139B4C44DBEA1810E3AA6F9000B87B915@SHSMSX101.ccr.corp.intel.com> In-Reply-To: <3CE959C139B4C44DBEA1810E3AA6F9000B87B915@SHSMSX101.ccr.corp.intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: 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: Thursday, November 28, 2019 10:23 AM > To: devel@edk2.groups.io; Gao, Zhichao > Cc: Carsey, Jaben ; Ni, Ray ; > Andrew Fish > Subject: RE: [edk2-devel] [PATCH] ShellPkg/UefiHandleParsingLib: Fix err= or > allocate pool >=20 > Hi Ray, >=20 > Can you 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 15, 2019 3:30 PM > > To: devel@edk2.groups.io > > Cc: Carsey, Jaben ; Ni, Ray = ; > > Andrew Fish > > Subject: [edk2-devel] [PATCH] ShellPkg/UefiHandleParsingLib: Fix error > allocate > > 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 > and > > 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 > > --- > > .../UefiHandleParsingLib/UefiHandleParsingLib.c | 12 ++++++++---= - > > 1 file changed, 8 insertions(+), 4 deletions(-) > > > > diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLi= b.c > > b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c > > index f179c41092..430c0ee70b 100644 > > --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c > > +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c > > @@ -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