diff options
author | Khem Raj <raj.khem@gmail.com> | 2018-05-28 08:58:31 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-06-15 17:56:57 +0100 |
commit | f50fe629313c25e9204052cda4a2ed0018f193d7 (patch) | |
tree | 2dbc85b142e585bf064c44fdc93714c85628c582 /meta/recipes-core | |
parent | 3ca535a09d17e772d7794d65f7e0950dd431a83a (diff) | |
download | poky-f50fe629313c25e9204052cda4a2ed0018f193d7.tar.gz |
systemd: Fix build with gcc8
(From OE-Core rev: 6a3805f06cd7832d70d5b652ec1be612f5f027e6)
(From OE-Core rev: 24e9ae887739f2ac6c3694b04c2c6159d6549be9)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core')
3 files changed, 177 insertions, 6 deletions
diff --git a/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch b/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch index b7b1ea0886..98c83620ff 100644 --- a/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch +++ b/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From 9820c165a9e559cf851e3beb60fad2571de4ded2 Mon Sep 17 00:00:00 2001 | 1 | From 7844e070745611a52e355b73e7890f360dd540d0 Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Mon, 14 Dec 2015 04:09:19 +0000 | 3 | Date: Mon, 14 Dec 2015 04:09:19 +0000 |
4 | Subject: [PATCH] core/device.c: Change the default device timeout to 240 sec. | 4 | Subject: [PATCH] core/device.c: Change the default device timeout to 240 sec. |
@@ -16,10 +16,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> | |||
16 | 1 file changed, 1 insertion(+), 1 deletion(-) | 16 | 1 file changed, 1 insertion(+), 1 deletion(-) |
17 | 17 | ||
18 | diff --git a/src/core/device.c b/src/core/device.c | 18 | diff --git a/src/core/device.c b/src/core/device.c |
19 | index 77601c552..98bf49ba2 100644 | 19 | index a43664d3b..4b16a8aec 100644 |
20 | --- a/src/core/device.c | 20 | --- a/src/core/device.c |
21 | +++ b/src/core/device.c | 21 | +++ b/src/core/device.c |
22 | @@ -112,7 +112,7 @@ static void device_init(Unit *u) { | 22 | @@ -113,7 +113,7 @@ static void device_init(Unit *u) { |
23 | * indefinitely for plugged in devices, something which cannot | 23 | * indefinitely for plugged in devices, something which cannot |
24 | * happen for the other units since their operations time out | 24 | * happen for the other units since their operations time out |
25 | * anyway. */ | 25 | * anyway. */ |
@@ -28,6 +28,3 @@ index 77601c552..98bf49ba2 100644 | |||
28 | 28 | ||
29 | u->ignore_on_isolate = true; | 29 | u->ignore_on_isolate = true; |
30 | } | 30 | } |
31 | -- | ||
32 | 2.16.1 | ||
33 | |||
diff --git a/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch b/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file mode 100644 index 0000000000..e56061f41b --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch | |||
@@ -0,0 +1,173 @@ | |||
1 | From c2b3ebe112ebfd9f9e82fb1531ee225c3152ca83 Mon Sep 17 00:00:00 2001 | ||
2 | From: Patrick Uiterwijk <patrick@puiterwijk.org> | ||
3 | Date: Thu, 22 Feb 2018 19:41:30 +0100 | ||
4 | Subject: [PATCH] Fix format-truncation compile failure by typecasting USB IDs | ||
5 | (#8250) | ||
6 | |||
7 | This patch adds safe_atoux16 for parsing an unsigned hexadecimal 16bit int, and | ||
8 | uses that for parsing USB device and vendor IDs. | ||
9 | |||
10 | This fixes a compile error with gcc-8 because while we know that USB IDs are 2 bytes, | ||
11 | the compiler does not know that. | ||
12 | |||
13 | ../src/udev/udev-builtin-hwdb.c:80:38: error: '%04X' directive output may be | ||
14 | truncated writing between 4 and 8 bytes into a region of size between 2 and 6 | ||
15 | [-Werror=format-truncation=] | ||
16 | |||
17 | Upstream-Status: Backport [https://github.com/systemd/systemd/commit/5547c12503a683290eaed47954ffcfb2d1bc03cd] | ||
18 | |||
19 | Signed-off-by: Adam Williamson <awilliam@redhat.com> | ||
20 | Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com> | ||
21 | --- | ||
22 | src/basic/parse-util.c | 24 ++++++++++++++++++++++ | ||
23 | src/basic/parse-util.h | 2 ++ | ||
24 | src/test/test-parse-util.c | 39 ++++++++++++++++++++++++++++++++++++ | ||
25 | src/udev/udev-builtin-hwdb.c | 13 ++++++------ | ||
26 | 4 files changed, 71 insertions(+), 7 deletions(-) | ||
27 | |||
28 | diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c | ||
29 | index 97533721d..ff3fc298a 100644 | ||
30 | --- a/src/basic/parse-util.c | ||
31 | +++ b/src/basic/parse-util.c | ||
32 | @@ -532,6 +532,30 @@ int safe_atoi16(const char *s, int16_t *ret) { | ||
33 | return 0; | ||
34 | } | ||
35 | |||
36 | +int safe_atoux16(const char *s, uint16_t *ret) { | ||
37 | + char *x = NULL; | ||
38 | + unsigned long l; | ||
39 | + | ||
40 | + assert(s); | ||
41 | + assert(ret); | ||
42 | + | ||
43 | + s += strspn(s, WHITESPACE); | ||
44 | + | ||
45 | + errno = 0; | ||
46 | + l = strtoul(s, &x, 16); | ||
47 | + if (errno > 0) | ||
48 | + return -errno; | ||
49 | + if (!x || x == s || *x != 0) | ||
50 | + return -EINVAL; | ||
51 | + if (s[0] == '-') | ||
52 | + return -ERANGE; | ||
53 | + if ((unsigned long) (uint16_t) l != l) | ||
54 | + return -ERANGE; | ||
55 | + | ||
56 | + *ret = (uint16_t) l; | ||
57 | + return 0; | ||
58 | +} | ||
59 | + | ||
60 | int safe_atod(const char *s, double *ret_d) { | ||
61 | _cleanup_(freelocalep) locale_t loc = (locale_t) 0; | ||
62 | char *x = NULL; | ||
63 | diff --git a/src/basic/parse-util.h b/src/basic/parse-util.h | ||
64 | index 1eda1d7f9..727422056 100644 | ||
65 | --- a/src/basic/parse-util.h | ||
66 | +++ b/src/basic/parse-util.h | ||
67 | @@ -54,6 +54,8 @@ int safe_atou8(const char *s, uint8_t *ret); | ||
68 | int safe_atou16(const char *s, uint16_t *ret); | ||
69 | int safe_atoi16(const char *s, int16_t *ret); | ||
70 | |||
71 | +int safe_atoux16(const char *s, uint16_t *ret); | ||
72 | + | ||
73 | static inline int safe_atou32(const char *s, uint32_t *ret_u) { | ||
74 | assert_cc(sizeof(uint32_t) == sizeof(unsigned)); | ||
75 | return safe_atou(s, (unsigned*) ret_u); | ||
76 | diff --git a/src/test/test-parse-util.c b/src/test/test-parse-util.c | ||
77 | index 937500213..a99cea5a1 100644 | ||
78 | --- a/src/test/test-parse-util.c | ||
79 | +++ b/src/test/test-parse-util.c | ||
80 | @@ -468,6 +468,44 @@ static void test_safe_atoi16(void) { | ||
81 | assert_se(r == -EINVAL); | ||
82 | } | ||
83 | |||
84 | +static void test_safe_atoux16(void) { | ||
85 | + int r; | ||
86 | + uint16_t l; | ||
87 | + | ||
88 | + r = safe_atoux16("1234", &l); | ||
89 | + assert_se(r == 0); | ||
90 | + assert_se(l == 0x1234); | ||
91 | + | ||
92 | + r = safe_atoux16("abcd", &l); | ||
93 | + assert_se(r == 0); | ||
94 | + assert_se(l == 0xabcd); | ||
95 | + | ||
96 | + r = safe_atoux16(" 1234", &l); | ||
97 | + assert_se(r == 0); | ||
98 | + assert_se(l == 0x1234); | ||
99 | + | ||
100 | + r = safe_atoux16("12345", &l); | ||
101 | + assert_se(r == -ERANGE); | ||
102 | + | ||
103 | + r = safe_atoux16("-1", &l); | ||
104 | + assert_se(r == -ERANGE); | ||
105 | + | ||
106 | + r = safe_atoux16(" -1", &l); | ||
107 | + assert_se(r == -ERANGE); | ||
108 | + | ||
109 | + r = safe_atoux16("junk", &l); | ||
110 | + assert_se(r == -EINVAL); | ||
111 | + | ||
112 | + r = safe_atoux16("123x", &l); | ||
113 | + assert_se(r == -EINVAL); | ||
114 | + | ||
115 | + r = safe_atoux16("12.3", &l); | ||
116 | + assert_se(r == -EINVAL); | ||
117 | + | ||
118 | + r = safe_atoux16("", &l); | ||
119 | + assert_se(r == -EINVAL); | ||
120 | +} | ||
121 | + | ||
122 | static void test_safe_atou64(void) { | ||
123 | int r; | ||
124 | uint64_t l; | ||
125 | @@ -745,6 +783,7 @@ int main(int argc, char *argv[]) { | ||
126 | test_safe_atolli(); | ||
127 | test_safe_atou16(); | ||
128 | test_safe_atoi16(); | ||
129 | + test_safe_atoux16(); | ||
130 | test_safe_atou64(); | ||
131 | test_safe_atoi64(); | ||
132 | test_safe_atod(); | ||
133 | diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin-hwdb.c | ||
134 | index ca7f7c230..dbfe02429 100644 | ||
135 | --- a/src/udev/udev-builtin-hwdb.c | ||
136 | +++ b/src/udev/udev-builtin-hwdb.c | ||
137 | @@ -27,6 +27,7 @@ | ||
138 | |||
139 | #include "alloc-util.h" | ||
140 | #include "hwdb-util.h" | ||
141 | +#include "parse-util.h" | ||
142 | #include "string-util.h" | ||
143 | #include "udev-util.h" | ||
144 | #include "udev.h" | ||
145 | @@ -63,7 +64,7 @@ int udev_builtin_hwdb_lookup(struct udev_device *dev, | ||
146 | |||
147 | static const char *modalias_usb(struct udev_device *dev, char *s, size_t size) { | ||
148 | const char *v, *p; | ||
149 | - int vn, pn; | ||
150 | + uint16_t vn, pn; | ||
151 | |||
152 | v = udev_device_get_sysattr_value(dev, "idVendor"); | ||
153 | if (!v) | ||
154 | @@ -71,12 +72,10 @@ static const char *modalias_usb(struct udev_device *dev, char *s, size_t size) { | ||
155 | p = udev_device_get_sysattr_value(dev, "idProduct"); | ||
156 | if (!p) | ||
157 | return NULL; | ||
158 | - vn = strtol(v, NULL, 16); | ||
159 | - if (vn <= 0) | ||
160 | - return NULL; | ||
161 | - pn = strtol(p, NULL, 16); | ||
162 | - if (pn <= 0) | ||
163 | - return NULL; | ||
164 | + if (safe_atoux16(v, &vn) < 0) | ||
165 | + return NULL; | ||
166 | + if (safe_atoux16(p, &pn) < 0) | ||
167 | + return NULL; | ||
168 | snprintf(s, size, "usb:v%04Xp%04X*", vn, pn); | ||
169 | return s; | ||
170 | } | ||
171 | -- | ||
172 | 2.17.0 | ||
173 | |||
diff --git a/meta/recipes-core/systemd/systemd_237.bb b/meta/recipes-core/systemd/systemd_237.bb index b7c2113255..c4743a6b9d 100644 --- a/meta/recipes-core/systemd/systemd_237.bb +++ b/meta/recipes-core/systemd/systemd_237.bb | |||
@@ -52,6 +52,7 @@ SRC_URI += "file://touchscreen.rules \ | |||
52 | file://0032-memfd.patch \ | 52 | file://0032-memfd.patch \ |
53 | file://0033-basic-macros-rename-noreturn-into-_noreturn_-8456.patch \ | 53 | file://0033-basic-macros-rename-noreturn-into-_noreturn_-8456.patch \ |
54 | file://libmount.patch \ | 54 | file://libmount.patch \ |
55 | file://0034-Fix-format-truncation-compile-failure-by-typecasting.patch \ | ||
55 | " | 56 | " |
56 | SRC_URI_append_qemuall = " file://0001-core-device.c-Change-the-default-device-timeout-to-2.patch" | 57 | SRC_URI_append_qemuall = " file://0001-core-device.c-Change-the-default-device-timeout-to-2.patch" |
57 | 58 | ||