From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: zhichao.gao@intel.com) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by groups.io with SMTP; Mon, 02 Sep 2019 01:51:23 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Sep 2019 01:51:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,457,1559545200"; d="scan'208";a="333507501" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga004.jf.intel.com with ESMTP; 02 Sep 2019 01:51:22 -0700 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 2 Sep 2019 01:51:22 -0700 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 2 Sep 2019 01:51:21 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.92]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.146]) with mapi id 14.03.0439.000; Mon, 2 Sep 2019 16:51:19 +0800 From: "Gao, Zhichao" 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 Thread-Topic: [edk2-devel] [PATCH V2] ShellPkg/UefiHandleParsingLib: Fix incorrect reallocate pool Thread-Index: AQHVQFrgGSxL3Rd2xk+XkyYQC0+UvKcYVhPw Date: Mon, 2 Sep 2019 08:51:19 +0000 Message-ID: <3CE959C139B4C44DBEA1810E3AA6F9000B833EE7@SHSMSX101.ccr.corp.intel.com> References: <20190722065756.18856-1-zhichao.gao@intel.com> <15B3A870E6EA7BDB.7925@groups.io> In-Reply-To: <15B3A870E6EA7BDB.7925@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, Please help to review this patch. Thanks, Zhichao > -----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 >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1965 >=20 > 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)". >=20 > Adjust the coding style of this function. >=20 > Cc: Jaben Carsey > Cc: Ray Ni > Cc: Andrew Fish > Signed-off-by: Zhichao Gao > --- >=20 > V2: > Update the copyright. >=20 > .../UefiHandleParsingLib/UefiHandleParsingLib.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) >=20 > diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.= 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 h= andle > and protocol database. >=20 > - Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. > + 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); >=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(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; >=20 > -- > 2.21.0.windows.1 >=20 >=20 >=20