From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.85.128.67, mailfrom: philmd@redhat.com) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by groups.io with SMTP; Tue, 23 Apr 2019 01:00:37 -0700 Received: by mail-wm1-f67.google.com with SMTP id o25so17401848wmf.5 for ; Tue, 23 Apr 2019 01:00:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Ib3UzcMQ+39oGkebpj0re//LCeeQrFhRd9G1Ub9F+Y8=; b=ci8eNPFU4VTW1WQJStWsG2AgNIT5FR8GFJAl7g1i/EoUiUDgEjZY1Wordo1KBT+CmD YQ3+HQlucZEyqaW/CP7YEzF9YikZfKN9HZyGw8UaOAYg4ks/vfu1NNKA5XvYllKWw83S n6JQkhWHziVgVHfey2BGjahqKKvss0+lisKoVXecbkdDjAPmu159yxYlOBnkX4R1Vmj0 vJTe1AwCJxELBCit2bomUSO0+SbnP5AQyfj0xppalOMc2/MObt8lM9RVSu7+DhZHoYJJ gqgxkJGf7tFvTvMkngZ3ILxzOic4aoCKltlNX04C4kCJNqHbJwzXBydfLCzm0Mifl2mZ mqoQ== X-Gm-Message-State: APjAAAW/K0WEaZHWHBz7QuY1ATA0hC44yWL4hcp5q6tg3P0fU7HxmlXN YGYI+l92JCWcR6dtwOistXM3Bw== X-Google-Smtp-Source: APXvYqwMumVMoWtRMyOKMCOZgi6tw+iX6wCIJFm+XpgYeeXl3OOeoy674LhHd3E1xN5n/mapJxjGzg== X-Received: by 2002:a1c:20c1:: with SMTP id g184mr1234865wmg.137.1556006435426; Tue, 23 Apr 2019 01:00:35 -0700 (PDT) Return-Path: Received: from [192.168.1.25] (atoulouse-656-1-803-163.w86-221.abo.wanadoo.fr. [86.221.12.163]) by smtp.gmail.com with ESMTPSA id y197sm15522754wmd.34.2019.04.23.01.00.32 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 01:00:34 -0700 (PDT) Subject: Re: [edk2-devel] [PATCH v2 3/5] BaseTools/PiFirmwareFile: fix undefined behavior in SECTION_SIZE To: devel@edk2.groups.io, lersek@redhat.com Cc: Bob Feng , Liming Gao , Yonghong Zhu References: <20190418174710.12236-1-lersek@redhat.com> <20190418174710.12236-4-lersek@redhat.com> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Openpgp: id=89C1E78F601EE86C867495CBA2A3FD6EDEADC0DE; url=http://pgp.mit.edu/pks/lookup?op=get&search=0xA2A3FD6EDEADC0DE Message-ID: <66c50d89-11be-9470-d403-e8031c3df018@redhat.com> Date: Tue, 23 Apr 2019 10:00:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190418174710.12236-4-lersek@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 4/18/19 7:47 PM, Laszlo Ersek wrote: > 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=1710 > Signed-off-by: Laszlo Ersek > --- > > 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() > > Reviewed-by: Philippe Mathieu-Daude