From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A096622361E71 for ; Wed, 7 Feb 2018 23:49:04 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Feb 2018 23:54:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,477,1511856000"; d="scan'208";a="29812547" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga001.jf.intel.com with ESMTP; 07 Feb 2018 23:54:46 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 7 Feb 2018 23:54:46 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.125]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.116]) with mapi id 14.03.0319.002; Thu, 8 Feb 2018 15:54:44 +0800 From: "Wu, Hao A" To: "Zhang, Chao B" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [PATCH] SecurityPkg: Tcg2Smm: Fix type casting issue Thread-Index: AQHToKWLv41WyfmptkGcs+lWj82zl6OaG4kw Date: Thu, 8 Feb 2018 07:54:44 +0000 Message-ID: References: <20180208062442.19060-1-chao.b.zhang@intel.com> In-Reply-To: <20180208062442.19060-1-chao.b.zhang@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] SecurityPkg: Tcg2Smm: Fix type casting issue X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Feb 2018 07:49:05 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Chao, The change is good to me. How about changing the commit title and body into: SecurityPkg/Tcg2Smm: Refine type cast for pointer subtraction Since the pointer subtraction here is not performed by pointers to elements of the same array object. This might lead to potential issues, such behavior is undefined according to C11 standard. Refine the pointer subtraction expressions by casting each pointer to UINTN first and then perform the subtraction. With the commit message change: Reviewed-by: Hao Wu Best Regards, Hao Wu > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Zhang, Chao B > Sent: Thursday, February 08, 2018 2:25 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A; Zhang, Chao B > Subject: [edk2] [PATCH] SecurityPkg: Tcg2Smm: Fix type casting issue >=20 > Fix type casting issue when calculating pointers offset >=20 > Cc: Wu Hao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Chao Zhang > --- > SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c > b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c > index 6eb62ae..c3cee83 100644 > --- a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c > +++ b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c > @@ -543,7 +543,7 @@ UpdatePossibleResource ( > // > DataPtr +=3D 2; > if (DataPtr < DataEndPtr) { > - SetMem(DataPtr, (UINTN)(DataEndPtr - DataPtr), AML_NOOP_OP); > + SetMem(DataPtr, (UINTN)DataEndPtr - (UINTN)DataPtr, AML_NOOP_OP); > } >=20 > return EFI_SUCCESS; > -- > 1.9.5.msysgit.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel