From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.1613.1574907782008439103 for ; Wed, 27 Nov 2019 18:23:02 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: zhichao.gao@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Nov 2019 18:23:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,251,1571727600"; d="scan'208";a="409209264" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga005.fm.intel.com with ESMTP; 27 Nov 2019 18:23:01 -0800 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 27 Nov 2019 18:23:01 -0800 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 27 Nov 2019 18:23:00 -0800 Received: from shsmsx105.ccr.corp.intel.com (10.239.4.158) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 27 Nov 2019 18:23:00 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.213]) by SHSMSX105.ccr.corp.intel.com ([169.254.11.225]) with mapi id 14.03.0439.000; Thu, 28 Nov 2019 10:22:58 +0800 From: "Gao, Zhichao" To: "devel@edk2.groups.io" , "Gao, Zhichao" CC: "Carsey, Jaben" , "Ni, Ray" , 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/HlhoMKegr2xg Date: Thu, 28 Nov 2019 02:22:57 +0000 Message-ID: <3CE959C139B4C44DBEA1810E3AA6F9000B87B915@SHSMSX101.ccr.corp.intel.com> References: <20190715073007.25732-1-zhichao.gao@intel.com> <15B1842A1397F2E7.11928@groups.io> In-Reply-To: <15B1842A1397F2E7.11928@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: zhichao.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Ray, Can you help to review this patch? Thanks, Zhichao > -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Ga= o, > 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 a= llocate > pool >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1965 >=20 > For function InsertNewGuidNameMapping, it rellocate the mGuidList with n= ew > 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)". >=20 > Adjust the coding style of this function. >=20 > 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(-) >=20 > diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.= 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); >=20 > - mGuidList =3D ReallocatePool(mGuidListCount * sizeof(GUID_INFO_BLOCK)= , > 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++; >=20 > - mGuidList[mGuidListCount - 1].GuidId =3D AllocateCopyPool(sizeof(EF= I_GUID), > Guid); > + mGuidList[mGuidListCount - 1].GuidId =3D AllocateCopyPool (sizeof (= EFI_GUID), > Guid); > mGuidList[mGuidListCount - 1].StringId =3D NameID; > mGuidList[mGuidListCount - 1].DumpInfo =3D DumpFunc; >=20 > -- > 2.21.0.windows.1 >=20 >=20 >=20