public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: Bob Feng <bob.c.feng@intel.com>,
	Liming Gao <liming.gao@intel.com>,
	Yonghong Zhu <yonghong.zhu@intel.com>
Cc: edk2-devel-groups-io <devel@edk2.groups.io>
Subject: Re: [edk2-devel] [PATCH v2 3/5] BaseTools/PiFirmwareFile: fix undefined behavior in SECTION_SIZE
Date: Tue, 23 Apr 2019 12:30:46 +0200	[thread overview]
Message-ID: <816906c6-cc85-52d9-7562-1b09f8b48402@redhat.com> (raw)
In-Reply-To: <20190418174710.12236-4-lersek@redhat.com>

Bob, Liming, Yonghong,

On 04/18/19 19:47, Laszlo Ersek wrote:
> 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(-)

can one of you please review this patch?

Thanks
Laszlo

> 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()
>  
> 


  parent reply	other threads:[~2019-04-23 10:30 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 [this message]
2019-04-23 11:47     ` Liming Gao
2019-04-23 11:56   ` Bob Feng
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=816906c6-cc85-52d9-7562-1b09f8b48402@redhat.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