From: "Bob Feng" <bob.c.feng@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
"lersek@redhat.com" <lersek@redhat.com>
Cc: "Gao, Liming" <liming.gao@intel.com>,
"Zhu, Yonghong" <yonghong.zhu@intel.com>
Subject: Re: [edk2-devel] [PATCH v2 3/5] BaseTools/PiFirmwareFile: fix undefined behavior in SECTION_SIZE
Date: Tue, 23 Apr 2019 11:56:17 +0000 [thread overview]
Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D1600E7336@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <20190418174710.12236-4-lersek@redhat.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Laszlo Ersek
Sent: Friday, April 19, 2019 1:47 AM
To: edk2-devel-groups-io <devel@edk2.groups.io>
Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [edk2-devel] [PATCH v2 3/5] BaseTools/PiFirmwareFile: fix undefined behavior in SECTION_SIZE
Sync SECTION_SIZE() from MdePkg to BaseTools, from an earlier patch in this series.
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=1710
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
Notes:
v2:
- 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;
-#define SECTION_SIZE(SectionHeaderPtr) \
- ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))
+//
+// The argument passed as the SectionHeaderPtr parameter to the
+SECTION_SIZE() // function-like macro below must not have side effects:
+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] <<
+16)))
#pragma pack()
--
2.19.1.3.g30247aa5d201
-=-=-=-=-=-=
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]
-=-=-=-=-=-=
next prev parent reply other threads:[~2019-04-23 11:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-18 17:47 [PATCH v2 0/5] patches for some warnings raised by "RH covscan" Laszlo Ersek
2019-04-18 17:47 ` [PATCH v2 1/5] MdePkg/PiFirmwareFile: express IS_SECTION2 in terms of SECTION_SIZE Laszlo Ersek
2019-04-18 17:47 ` [PATCH v2 2/5] MdePkg/PiFirmwareFile: fix undefined behavior in SECTION_SIZE Laszlo Ersek
2019-04-23 8:00 ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-18 17:47 ` [PATCH v2 3/5] BaseTools/PiFirmwareFile: " Laszlo Ersek
2019-04-23 8:00 ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-23 10:30 ` Laszlo Ersek
2019-04-23 11:47 ` Liming Gao
2019-04-23 11:56 ` Bob Feng [this message]
2019-04-18 17:47 ` [PATCH v2 4/5] MdePkg/PiFirmwareFile: fix undefined behavior in FFS_FILE_SIZE Laszlo Ersek
2019-04-23 8:00 ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-18 17:47 ` [PATCH v2 5/5] OvmfPkg/Sec: fix out-of-bounds reads Laszlo Ersek
2019-04-18 19:57 ` [PATCH v2 0/5] patches for some warnings raised by "RH covscan" Michael D Kinney
2019-04-18 20:03 ` Jordan Justen
2019-04-24 15:35 ` [edk2-devel] " Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=08650203BA1BD64D8AD9B6D5D74A85D1600E7336@SHSMSX101.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox