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: bob.c.feng@intel.com) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by groups.io with SMTP; Tue, 23 Apr 2019 04:56:20 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Apr 2019 04:56:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,385,1549958400"; d="scan'208";a="164247375" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga004.fm.intel.com with ESMTP; 23 Apr 2019 04:56:19 -0700 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 23 Apr 2019 04:56:19 -0700 Received: from shsmsx154.ccr.corp.intel.com (10.239.6.54) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 23 Apr 2019 04:56:19 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.164]) by SHSMSX154.ccr.corp.intel.com ([169.254.7.149]) with mapi id 14.03.0415.000; Tue, 23 Apr 2019 19:56:17 +0800 From: "Bob Feng" To: "devel@edk2.groups.io" , "lersek@redhat.com" CC: "Gao, Liming" , "Zhu, Yonghong" Subject: Re: [edk2-devel] [PATCH v2 3/5] BaseTools/PiFirmwareFile: fix undefined behavior in SECTION_SIZE Thread-Topic: [edk2-devel] [PATCH v2 3/5] BaseTools/PiFirmwareFile: fix undefined behavior in SECTION_SIZE Thread-Index: AQHU9g7P+UxB053no0W3msaJUjnLP6ZJqnIw Date: Tue, 23 Apr 2019 11:56:17 +0000 Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D1600E7336@SHSMSX101.ccr.corp.intel.com> References: <20190418174710.12236-1-lersek@redhat.com> <20190418174710.12236-4-lersek@redhat.com> In-Reply-To: <20190418174710.12236-4-lersek@redhat.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 Return-Path: bob.c.feng@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bob Feng -----Original Message----- From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Laszl= o Ersek Sent: Friday, April 19, 2019 1:47 AM To: edk2-devel-groups-io Cc: Feng, Bob C ; Gao, Liming ;= Zhu, Yonghong Subject: [edk2-devel] [PATCH v2 3/5] BaseTools/PiFirmwareFile: fix undefine= d behavior in SECTION_SIZE Sync SECTION_SIZE() from MdePkg to BaseTools, from an earlier patch in this= series. Cc: Bob Feng Cc: Liming Gao Cc: Yonghong Zhu Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1710 Signed-off-by: Laszlo Ersek --- Notes: v2: =20 - sync with the v2 MdePkg/PiFirmwareFile SECTION_SIZE patch BaseTools/Source/C/Include/Common/PiFirmwareFile.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/C/Include/Common/PiFirmwareFile.h b/BaseTools= /Source/C/Include/Common/PiFirmwareFile.h index 5bc871df4855..7d8acb669b69 100644 --- a/BaseTools/Source/C/Include/Common/PiFirmwareFile.h +++ b/BaseTools/Source/C/Include/Common/PiFirmwareFile.h @@ -300,8 +300,15 @@ typedef struct { CHAR16 VersionString[1]; } EFI_VERSION_SECTION2; =20 -#define SECTION_SIZE(SectionHeaderPtr) \ - ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPt= r)->Size) & 0x00ffffff)) +// +// The argument passed as the SectionHeaderPtr parameter to the=20 +SECTION_SIZE() // function-like macro below must not have side effects:=20 +SectionHeaderPtr is // evaluated multiple times. +// +#define SECTION_SIZE(SectionHeaderPtr) ((UINT32) ( \ + (((EFI_COMMON_SECTION_HEADER *) (SectionHeaderPtr))->Size[0] ) | = \ + (((EFI_COMMON_SECTION_HEADER *) (SectionHeaderPtr))->Size[1] << 8) | = \ + (((EFI_COMMON_SECTION_HEADER *) (SectionHeaderPtr))->Size[2] <<=20 +16))) =20 #pragma pack() =20 -- 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D Groups.io Links: You receive all messages sent to this group. View/Reply Online (#39309): https://edk2.groups.io/g/devel/message/39309 Mute This Topic: https://groups.io/mt/31233851/1768742 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [bob.c.feng@intel.com] -=3D-=3D-=3D-=3D-=3D-=3D