]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/efivar-37-compile-fixes-1.patch
suricata: Change midstream policy to "pass-flow"
[ipfire-2.x.git] / src / patches / efivar-37-compile-fixes-1.patch
1 From b98ba8921010d03f46704a476c69861515deb1ca Mon Sep 17 00:00:00 2001
2 From: Peter Jones <pjones@redhat.com>
3 Date: Mon, 7 Jan 2019 10:30:59 -0500
4 Subject: [PATCH] dp.h: make format_guid() handle misaligned guid pointers
5 safely.
6
7 GCC 9 adds -Werror=address-of-packed-member, which causes us to see the
8 build error reported at
9 https://bugzilla.opensuse.org/show_bug.cgi?id=1120862 .
10
11 That bug report shows us the following:
12
13 In file included from dp.c:26:
14 dp.h: In function 'format_vendor_helper':
15 dp.h:120:37: error: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Werror=address-of-packed-member]
16 120 | format_guid(buf, size, off, label, &dp->hw_vendor.vendor_guid);
17 | ^~~~~~~~~~~~~~~~~~~~~~~~~~
18 dp.h:74:25: note: in definition of macro 'format_guid'
19 74 | _rc = efi_guid_to_str(guid, &_guidstr); \
20 | ^~~~
21 cc1: all warnings being treated as errors
22
23 This patch makes format_guid() use a local variable as a bounce buffer
24 in the case that the guid we're passed is aligned as chaotic neutral.
25
26 Note that this only fixes this instance and there may be others that bz
27 didn't show because it exited too soon, and I don't have a gcc 9 build
28 in front of me right now.
29
30 Signed-off-by: Peter Jones <pjones@redhat.com>
31 ---
32 src/dp.h | 11 +++++++++--
33 1 file changed, 9 insertions(+), 2 deletions(-)
34
35 diff --git a/src/dp.h b/src/dp.h
36 index aa4e390..20cb608 100644
37 --- a/src/dp.h
38 +++ b/src/dp.h
39 @@ -70,8 +70,15 @@
40 #define format_guid(buf, size, off, dp_type, guid) ({ \
41 int _rc; \
42 char *_guidstr = NULL; \
43 - \
44 - _rc = efi_guid_to_str(guid, &_guidstr); \
45 + efi_guid_t _guid; \
46 + const efi_guid_t * const _guid_p = \
47 + likely(__alignof__(guid) == sizeof(guid)) \
48 + ? guid \
49 + : &_guid; \
50 + \
51 + if (unlikely(__alignof__(guid) == sizeof(guid))) \
52 + memmove(&_guid, guid, sizeof(_guid)); \
53 + _rc = efi_guid_to_str(_guid_p, &_guidstr); \
54 if (_rc < 0) { \
55 efi_error("could not build %s GUID DP string", \
56 dp_type); \