systemd: Fix build with gcc8
PATCH 1/3 systemd: Fix build with gcc8
--- ...ange-the-default-device-timeout-to-2.patch | 9 +- ...ation-compile-failure-by-typecasting.patch | 173 ++++++++++++++++++ meta/recipes-core/systemd/systemd_237.bb | 1 + 3 files changed, 177 insertions(+), 6 deletions(-) create mode 100644 meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch
meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch +3 -6
@@ -1,4 +1,4 @@ -From 9820c165a9e559cf851e3beb60fad2571de4ded2 Mon Sep 17 00:00:00 2001 +From 7844e070745611a52e355b73e7890f360dd540d0 Mon Sep 17 00:00:00 2001 From: Khem Raj <[email protected]> Date: Mon, 14 Dec 2015 04:09:19 +0000 Subject: [PATCH] core/device.c: Change the default device timeout to 240 sec.
@@ -16,10 +16,10 @@ Signed-off-by: Khem Raj <[email protected]> 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/device.c b/src/core/device.c -index 77601c552..98bf49ba2 100644 +index a43664d3b..4b16a8aec 100644 --- a/src/core/device.c +++ b/src/core/device.c -@@ -112,7 +112,7 @@ static void device_init(Unit *u) { +@@ -113,7 +113,7 @@ static void device_init(Unit *u) { * indefinitely for plugged in devices, something which cannot * happen for the other units since their operations time out * anyway. */
@@ -28,6 +28,3 @@ index 77601c552..98bf49ba2 100644 u->ignore_on_isolate = true; } --- -2.16.1 -
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +173 -0
173 lines not on this page · raw message
meta/recipes-core/systemd/systemd_237.bb +1 -0
@@ -52,6 +52,7 @@ SRC_URI += "file://touchscreen.rules \ file://0032-memfd.patch \ file://0033-basic-macros-rename-noreturn-into-_noreturn_-8456.patch \ file://libmount.patch \ + file://0034-Fix-format-truncation-compile-failure-by-typecasting.patch \ " SRC_URI_append_qemuall = " file://0001-core-device.c-Change-the-default-device-timeout-to-2.patch"
Signature · 1 line
2.17.0
PATCH 2/3 systemd: Define basename() for musl
--- ...patible-basename-for-non-glibc-syste.patch | 33 +++++++++++++++++++ meta/recipes-core/systemd/systemd_237.bb | 1 + 2 files changed, 34 insertions(+) create mode 100644 meta/recipes-core/systemd/systemd/0035-Define-glibc-compatible-basename-for-non-glibc-syste.patch
meta/recipes-core/systemd/systemd/0035-Define-glibc-compatible-basename-for-non-glibc-syste.patch new file +33 -0
@@ -0,0 +1,33 @@ +From 5f1f064c81ea30acf93cfa0fb466b38f094f488c Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Sun, 27 May 2018 08:36:44 -0700 +Subject: [PATCH] Define glibc compatible basename() for non-glibc systems + +Fixes builds with musl, even though systemd is adamant about +using non-posix basename implementation, we have a way out + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Khem Raj <[email protected]> +--- + src/machine/machine-dbus.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c +index 2d7806491b..9a3bdb1d76 100644 +--- a/src/machine/machine-dbus.c ++++ b/src/machine/machine-dbus.c +@@ -29,6 +29,10 @@ + #include <libgen.h> + #undef basename + ++#if !defined(__GLIBC__) ++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src) ++#endif ++ + #include "alloc-util.h" + #include "bus-common-errors.h" + #include "bus-internal.h" +-- +2.17.0 +
meta/recipes-core/systemd/systemd_237.bb +1 -0
@@ -53,6 +53,7 @@ SRC_URI += "file://touchscreen.rules \ file://0033-basic-macros-rename-noreturn-into-_noreturn_-8456.patch \ file://libmount.patch \ file://0034-Fix-format-truncation-compile-failure-by-typecasting.patch \ + file://0035-Define-glibc-compatible-basename-for-non-glibc-syste.patch \ " SRC_URI_append_qemuall = " file://0001-core-device.c-Change-the-default-device-timeout-to-2.patch"
Signature · 1 line
2.17.0
PATCH 3/3 rpcsvc-proto: Update to 1.4
In reply to Khem RajBring in an important fix
https://bugzilla.redhat.com/show_bug.cgi?id=1559181
--- meta/recipes-extended/rpcsvc-proto/rpcsvc-proto.bb | 4 ++-- .../0001-Use-cross-compiled-rpcgen.patch | 13 +++++-------- 2 files changed, 7 insertions(+), 10 deletions(-)
meta/recipes-extended/rpcsvc-proto/rpcsvc-proto.bb +2 -2
@@ -15,9 +15,9 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=0daaf958d5531ab86169ec6e275e1517" SECTION = "libs" DEPENDS += "rpcsvc-proto-native" -PV = "1.3.1+git${SRCPV}" +PV = "1.4+git${SRCPV}" -SRCREV = "abcf24a09665b3def0f54c87d2acd4796de5d83a" +SRCREV = "9bc3b5b785723cfff459b0c01b39d87d4bed975c" SRC_URI = "git://github.com/thkukuk/${BPN} \ file://0001-Use-cross-compiled-rpcgen.patch \
meta/recipes-extended/rpcsvc-proto/rpcsvc-proto/0001-Use-cross-compiled-rpcgen.patch +5 -8
@@ -10,17 +10,14 @@ Signed-off-by: Khem Raj <[email protected]> rpcsvc/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -diff --git a/rpcsvc/Makefile.am b/rpcsvc/Makefile.am -index 83867c0..4753242 100644 ---- a/rpcsvc/Makefile.am -+++ b/rpcsvc/Makefile.am -@@ -12,5 +12,5 @@ nodist_rpcsvc_HEADERS = klm_prot.h nlm_prot.h rstat.h spray.h \ +Index: git/rpcsvc/Makefile.am +=================================================================== +--- git.orig/rpcsvc/Makefile.am ++++ git/rpcsvc/Makefile.am +@@ -12,5 +12,5 @@ nodist_rpcsvc_HEADERS = klm_prot.h nlm_p nfs_prot.h rquota.h sm_inter.h %.h: %.x - $(top_builddir)/rpcgen/rpcgen -h -o $@ $< + rpcgen -h -o $@ $< --- -2.17.0 -
Signature · 1 line
2.17.0
Unlike the previous version you had in your RFT branch (which added -Wno-error=format-truncation) this doesn't seem to be complete fix.
In qemux86 build which already includes this change I'm seeing:../git/src/basic/time-util.c: In function 'format_timespan':../git/src/basic/time-util.c:508:46: error: '%0*llu' directive output between 1 and 2147483647 bytes may cause result to exceed 'INT_MAX' [-Werror=format-truncation=]
"%s"USEC_FMT".%0*"PRI_USEC"%s",
^~~~
../git/src/basic/time-util.c:508:60: note: format string is defined here
"%s"USEC_FMT".%0*"PRI_USEC"%s", ../git/src/basic/time-util.c:508:46: note: directive argument in the range [0, 18446744073709551614]
"%s"USEC_FMT".%0*"PRI_USEC"%s",
^~~~
And this part doesn't seem to be fixed upstream yet.
Cheers,
Quoted 260 lines · Khem Raj
Signed-off-by Khem Raj <[email protected]>--- ...ange-the-default-device-timeout-to-2.patch | 9 +- ...ation-compile-failure-by-typecasting.patch | 173 ++++++++++++++++++ meta/recipes-core/systemd/systemd_237.bb | 1 + 3 files changed, 177 insertions(+), 6 deletions(-) create mode 100644
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patchdiff --git
a/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patchb/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patchindexb7b1ea0886..98c83620ff100644
---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.patchmeta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch +1
-1@@ -1,4 +1,4 @@ -From 9820c165a9e559cf851e3beb60fad2571de4ded2 Mon Sep 17 00:00:00 2001 +From 7844e070745611a52e355b73e7890f360dd540d0 Mon Sep 17 00:00:00 2001 From: Khem Raj <[email protected]> Date: Mon, 14 Dec 2015 04:09:19 +0000 Subject: [PATCH] core/device.c: Change the default device timeout to 240sec.
meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch +2
-5@@ -16,10 +16,10 @@ Signed-off-by: Khem Raj <[email protected]> 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/device.c b/src/core/device.c -index 77601c552..98bf49ba2 100644 +index a43664d3b..4b16a8aec 100644 --- a/src/core/device.c +++ b/src/core/device.c -@@ -112,7 +112,7 @@ static void device_init(Unit *u) { +@@ -113,7 +113,7 @@ static void device_init(Unit *u) { * indefinitely for plugged in devices, something which cannot * happen for the other units since their operations time out * anyway. */@@ -28,6 +28,3 @@ index 77601c552..98bf49ba2 100644 u->ignore_on_isolate = true; } --- -2.16.1 -diff --git
a/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patchb/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patchnew file mode 100644
index 0000000000..e56061f41b
---/dev/null
+++b/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patchmeta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +4
-0@@ -0,0 +1,173 @@ +From c2b3ebe112ebfd9f9e82fb1531ee225c3152ca83 Mon Sep 17 00:00:00 2001 +From: Patrick Uiterwijk <[email protected]> +Date: Thu, 22 Feb 2018 19:41:30 +0100 +Subject: [PATCH] Fix format-truncation compile failure by typecasting USBIDs
+ (#8250)(quoted diff) +2
-0+ +This patch adds safe_atoux16 for parsing an unsigned hexadecimal 16bitint, and
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +3
-0+uses that for parsing USB device and vendor IDs. + +This fixes a compile error with gcc-8 because while we know that USB IDsare 2 bytes,
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +3
-0+the compiler does not know that. + +../src/udev/udev-builtin-hwdb.c:80:38: error: '%04X' directive output maybe
+truncated writing between 4 and 8 bytes into a region of size between 2 and 6
+[-Werror=format-truncation=](quoted diff) +2
-0+ +Upstream-Status: Backport [https://github.com/systemd/systemd/commit/5547c12503a683290eaed47954ffcfb2d1bc03cd
]meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +130
-0+ +Signed-off-by: Adam Williamson <[email protected]> +Signed-off-by: Patrick Uiterwijk <[email protected]> +--- + src/basic/parse-util.c | 24 ++++++++++++++++++++++ + src/basic/parse-util.h | 2 ++ + src/test/test-parse-util.c | 39 ++++++++++++++++++++++++++++++++++++ + src/udev/udev-builtin-hwdb.c | 13 ++++++------ + 4 files changed, 71 insertions(+), 7 deletions(-) + +diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c +index 97533721d..ff3fc298a 100644 +--- a/src/basic/parse-util.c ++++ b/src/basic/parse-util.c +@@ -532,6 +532,30 @@ int safe_atoi16(const char *s, int16_t *ret) { + return 0; + } + ++int safe_atoux16(const char *s, uint16_t *ret) { ++ char *x = NULL; ++ unsigned long l; ++ ++ assert(s); ++ assert(ret); ++ ++ s += strspn(s, WHITESPACE); ++ ++ errno = 0; ++ l = strtoul(s, &x, 16); ++ if (errno > 0) ++ return -errno; ++ if (!x || x == s || *x != 0) ++ return -EINVAL; ++ if (s[0] == '-') ++ return -ERANGE; ++ if ((unsigned long) (uint16_t) l != l) ++ return -ERANGE; ++ ++ *ret = (uint16_t) l; ++ return 0; ++} ++ + int safe_atod(const char *s, double *ret_d) { + _cleanup_(freelocalep) locale_t loc = (locale_t) 0; + char *x = NULL; +diff --git a/src/basic/parse-util.h b/src/basic/parse-util.h +index 1eda1d7f9..727422056 100644 +--- a/src/basic/parse-util.h ++++ b/src/basic/parse-util.h +@@ -54,6 +54,8 @@ int safe_atou8(const char *s, uint8_t *ret); + int safe_atou16(const char *s, uint16_t *ret); + int safe_atoi16(const char *s, int16_t *ret); + ++int safe_atoux16(const char *s, uint16_t *ret); ++ + static inline int safe_atou32(const char *s, uint32_t *ret_u) { + assert_cc(sizeof(uint32_t) == sizeof(unsigned)); + return safe_atou(s, (unsigned*) ret_u); +diff --git a/src/test/test-parse-util.c b/src/test/test-parse-util.c +index 937500213..a99cea5a1 100644 +--- a/src/test/test-parse-util.c ++++ b/src/test/test-parse-util.c +@@ -468,6 +468,44 @@ static void test_safe_atoi16(void) { + assert_se(r == -EINVAL); + } + ++static void test_safe_atoux16(void) { ++ int r; ++ uint16_t l; ++ ++ r = safe_atoux16("1234", &l); ++ assert_se(r == 0); ++ assert_se(l == 0x1234); ++ ++ r = safe_atoux16("abcd", &l); ++ assert_se(r == 0); ++ assert_se(l == 0xabcd); ++ ++ r = safe_atoux16(" 1234", &l); ++ assert_se(r == 0); ++ assert_se(l == 0x1234); ++ ++ r = safe_atoux16("12345", &l); ++ assert_se(r == -ERANGE); ++ ++ r = safe_atoux16("-1", &l); ++ assert_se(r == -ERANGE); ++ ++ r = safe_atoux16(" -1", &l); ++ assert_se(r == -ERANGE); ++ ++ r = safe_atoux16("junk", &l); ++ assert_se(r == -EINVAL); ++ ++ r = safe_atoux16("123x", &l); ++ assert_se(r == -EINVAL); ++ ++ r = safe_atoux16("12.3", &l); ++ assert_se(r == -EINVAL); ++ ++ r = safe_atoux16("", &l); ++ assert_se(r == -EINVAL); ++} ++ + static void test_safe_atou64(void) { + int r; + uint64_t l; +@@ -745,6 +783,7 @@ int main(int argc, char *argv[]) { + test_safe_atolli(); + test_safe_atou16(); + test_safe_atoi16(); ++ test_safe_atoux16(); + test_safe_atou64(); + test_safe_atoi64(); + test_safe_atod(); +diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin-hwdb.c +index ca7f7c230..dbfe02429 100644 +--- a/src/udev/udev-builtin-hwdb.c ++++ b/src/udev/udev-builtin-hwdb.c +@@ -27,6 +27,7 @@ + + #include "alloc-util.h" + #include "hwdb-util.h" ++#include "parse-util.h" + #include "string-util.h" + #include "udev-util.h" + #include "udev.h" +@@ -63,7 +64,7 @@ int udev_builtin_hwdb_lookup(struct udev_device *dev, + + static const char *modalias_usb(struct udev_device *dev, char *s, size_tsize) {
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +7
-0+ const char *v, *p; +- int vn, pn; ++ uint16_t vn, pn; + + v = udev_device_get_sysattr_value(dev, "idVendor"); + if (!v) +@@ -71,12 +72,10 @@ static const char *modalias_usb(struct udev_device*dev, char *s,
size_tsize) {meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +19
-0+ p = udev_device_get_sysattr_value(dev, "idProduct"); + if (!p) + return NULL; +- vn = strtol(v, NULL, 16); +- if (vn <= 0) +- return NULL; +- pn = strtol(p, NULL, 16); +- if (pn <= 0) +- return NULL; ++ if (safe_atoux16(v, &vn) < 0) ++ return NULL; ++ if (safe_atoux16(p, &pn) < 0) ++ return NULL; + snprintf(s, size, "usb:v%04Xp%04X*", vn, pn); + return s; + } +-- +2.17.0 +meta/recipes-core/systemd/systemd_237.bb +1
-0@@ -52,6 +52,7 @@ SRC_URI += "file://touchscreen.rules \ file://0032-memfd.patch \ file://0033-basic-macros-rename-noreturn-into-_noreturn_-8456.patch \ file://libmount.patch \ + file://0034-Fix-format-truncation-compile-failure-by-typecasting.patch \ "
SRC_URI_append_qemuall= "
file://0001-core-device.c-Change-the-default-device-timeout-to-2.patch"--
2.17.0--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Quoted 13 lines · Martin Jansa
Unlike the previous version you had in your RFT branch (which added -Wno-error=format-truncation) this doesn't seem to be complete fix.
In qemux86 build which already includes this change I'm seeing:
../git/src/basic/time-util.c: In function 'format_timespan':../git/src/basic/time-util.c:508:46: error: '%0*llu' directive output between 1 and 2147483647 bytes may cause result to exceed 'INT_MAX' [-Werror=format-truncation=]"%s"USEC_FMT".%0*"PRI_USEC"%s",
^~~~
../git/src/basic/time-util.c:508:60: note: format string is defined here
Quoted 9 lines
"%s"USEC_FMT".%0*"PRI_USEC"%s",
../git/src/basic/time-util.c:508:46: note: directive argument in the range [0, 18446744073709551614]"%s"USEC_FMT".%0*"PRI_USEC"%s",
^~~~And this part doesn't seem to be fixed upstream yet.
Its possible, that default config I build is not using this code. Do you enable/disable some specific packageconfig and what arch are you targetting
Quoted 262 lines
Cheers,
Quoted 259 lines · Khem Raj
Signed-off-by Khem Raj <[email protected]>--- ...ange-the-default-device-timeout-to-2.patch | 9 +- ...ation-compile-failure-by-typecasting.patch | 173 ++++++++++++++++++ meta/recipes-core/systemd/systemd_237.bb | 1 + 3 files changed, 177 insertions(+), 6 deletions(-) create mode 100644
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patchdiff --git
a/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patchb/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patchindexb7b1ea0886..98c83620ff100644
---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.patchmeta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch +1
-1@@ -1,4 +1,4 @@ -From 9820c165a9e559cf851e3beb60fad2571de4ded2 Mon Sep 17 00:00:00 2001 +From 7844e070745611a52e355b73e7890f360dd540d0 Mon Sep 17 00:00:00 2001 From: Khem Raj <[email protected]> Date: Mon, 14 Dec 2015 04:09:19 +0000 Subject: [PATCH] core/device.c: Change the default device timeout to 240sec.
meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch +2
-5@@ -16,10 +16,10 @@ Signed-off-by: Khem Raj <[email protected]> 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/device.c b/src/core/device.c -index 77601c552..98bf49ba2 100644 +index a43664d3b..4b16a8aec 100644 --- a/src/core/device.c +++ b/src/core/device.c -@@ -112,7 +112,7 @@ static void device_init(Unit *u) { +@@ -113,7 +113,7 @@ static void device_init(Unit *u) { * indefinitely for plugged in devices, something which cannot * happen for the other units since their operations time out * anyway. */@@ -28,6 +28,3 @@ index 77601c552..98bf49ba2 100644 u->ignore_on_isolate = true; } --- -2.16.1 -diff --git
a/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patchb/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patchnew file mode 100644
index 0000000000..e56061f41b
---/dev/null
+++b/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patchmeta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +4
-0@@ -0,0 +1,173 @@ +From c2b3ebe112ebfd9f9e82fb1531ee225c3152ca83 Mon Sep 17 00:00:00 2001 +From: Patrick Uiterwijk <[email protected]> +Date: Thu, 22 Feb 2018 19:41:30 +0100 +Subject: [PATCH] Fix format-truncation compile failure by typecasting USBIDs
+ (#8250)(quoted diff) +2
-0+ +This patch adds safe_atoux16 for parsing an unsigned hexadecimal 16bitint, and
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +3
-0+uses that for parsing USB device and vendor IDs. + +This fixes a compile error with gcc-8 because while we know that USB IDsare 2 bytes,
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +3
-0+the compiler does not know that. + +../src/udev/udev-builtin-hwdb.c:80:38: error: '%04X' directive output maybe
+truncated writing between 4 and 8 bytes into a region of size between 2 and 6
+[-Werror=format-truncation=](quoted diff) +2
-0+ +Upstream-Status: Backport[https://github.com/systemd/systemd/commit/5547c12503a683290eaed47954ffcfb2d1bc03cd]
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +130
-0+ +Signed-off-by: Adam Williamson <[email protected]> +Signed-off-by: Patrick Uiterwijk <[email protected]> +--- + src/basic/parse-util.c | 24 ++++++++++++++++++++++ + src/basic/parse-util.h | 2 ++ + src/test/test-parse-util.c | 39 ++++++++++++++++++++++++++++++++++++ + src/udev/udev-builtin-hwdb.c | 13 ++++++------ + 4 files changed, 71 insertions(+), 7 deletions(-) + +diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c +index 97533721d..ff3fc298a 100644 +--- a/src/basic/parse-util.c ++++ b/src/basic/parse-util.c +@@ -532,6 +532,30 @@ int safe_atoi16(const char *s, int16_t *ret) { + return 0; + } + ++int safe_atoux16(const char *s, uint16_t *ret) { ++ char *x = NULL; ++ unsigned long l; ++ ++ assert(s); ++ assert(ret); ++ ++ s += strspn(s, WHITESPACE); ++ ++ errno = 0; ++ l = strtoul(s, &x, 16); ++ if (errno > 0) ++ return -errno; ++ if (!x || x == s || *x != 0) ++ return -EINVAL; ++ if (s[0] == '-') ++ return -ERANGE; ++ if ((unsigned long) (uint16_t) l != l) ++ return -ERANGE; ++ ++ *ret = (uint16_t) l; ++ return 0; ++} ++ + int safe_atod(const char *s, double *ret_d) { + _cleanup_(freelocalep) locale_t loc = (locale_t) 0; + char *x = NULL; +diff --git a/src/basic/parse-util.h b/src/basic/parse-util.h +index 1eda1d7f9..727422056 100644 +--- a/src/basic/parse-util.h ++++ b/src/basic/parse-util.h +@@ -54,6 +54,8 @@ int safe_atou8(const char *s, uint8_t *ret); + int safe_atou16(const char *s, uint16_t *ret); + int safe_atoi16(const char *s, int16_t *ret); + ++int safe_atoux16(const char *s, uint16_t *ret); ++ + static inline int safe_atou32(const char *s, uint32_t *ret_u) { + assert_cc(sizeof(uint32_t) == sizeof(unsigned)); + return safe_atou(s, (unsigned*) ret_u); +diff --git a/src/test/test-parse-util.c b/src/test/test-parse-util.c +index 937500213..a99cea5a1 100644 +--- a/src/test/test-parse-util.c ++++ b/src/test/test-parse-util.c +@@ -468,6 +468,44 @@ static void test_safe_atoi16(void) { + assert_se(r == -EINVAL); + } + ++static void test_safe_atoux16(void) { ++ int r; ++ uint16_t l; ++ ++ r = safe_atoux16("1234", &l); ++ assert_se(r == 0); ++ assert_se(l == 0x1234); ++ ++ r = safe_atoux16("abcd", &l); ++ assert_se(r == 0); ++ assert_se(l == 0xabcd); ++ ++ r = safe_atoux16(" 1234", &l); ++ assert_se(r == 0); ++ assert_se(l == 0x1234); ++ ++ r = safe_atoux16("12345", &l); ++ assert_se(r == -ERANGE); ++ ++ r = safe_atoux16("-1", &l); ++ assert_se(r == -ERANGE); ++ ++ r = safe_atoux16(" -1", &l); ++ assert_se(r == -ERANGE); ++ ++ r = safe_atoux16("junk", &l); ++ assert_se(r == -EINVAL); ++ ++ r = safe_atoux16("123x", &l); ++ assert_se(r == -EINVAL); ++ ++ r = safe_atoux16("12.3", &l); ++ assert_se(r == -EINVAL); ++ ++ r = safe_atoux16("", &l); ++ assert_se(r == -EINVAL); ++} ++ + static void test_safe_atou64(void) { + int r; + uint64_t l; +@@ -745,6 +783,7 @@ int main(int argc, char *argv[]) { + test_safe_atolli(); + test_safe_atou16(); + test_safe_atoi16(); ++ test_safe_atoux16(); + test_safe_atou64(); + test_safe_atoi64(); + test_safe_atod(); +diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin-hwdb.c +index ca7f7c230..dbfe02429 100644 +--- a/src/udev/udev-builtin-hwdb.c ++++ b/src/udev/udev-builtin-hwdb.c +@@ -27,6 +27,7 @@ + + #include "alloc-util.h" + #include "hwdb-util.h" ++#include "parse-util.h" + #include "string-util.h" + #include "udev-util.h" + #include "udev.h" +@@ -63,7 +64,7 @@ int udev_builtin_hwdb_lookup(struct udev_device *dev, + + static const char *modalias_usb(struct udev_device *dev, char *s, size_tsize) {
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +7
-0+ const char *v, *p; +- int vn, pn; ++ uint16_t vn, pn; + + v = udev_device_get_sysattr_value(dev, "idVendor"); + if (!v) +@@ -71,12 +72,10 @@ static const char *modalias_usb(struct udev_device*dev, char *s,
size_tsize) {meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +19
-0+ p = udev_device_get_sysattr_value(dev, "idProduct"); + if (!p) + return NULL; +- vn = strtol(v, NULL, 16); +- if (vn <= 0) +- return NULL; +- pn = strtol(p, NULL, 16); +- if (pn <= 0) +- return NULL; ++ if (safe_atoux16(v, &vn) < 0) ++ return NULL; ++ if (safe_atoux16(p, &pn) < 0) ++ return NULL; + snprintf(s, size, "usb:v%04Xp%04X*", vn, pn); + return s; + } +-- +2.17.0 +meta/recipes-core/systemd/systemd_237.bb +1
-0@@ -52,6 +52,7 @@ SRC_URI += "file://touchscreen.rules \ file://0032-memfd.patch \ file://0033-basic-macros-rename-noreturn-into-_noreturn_-8456.patch \ file://libmount.patch \ + file://0034-Fix-format-truncation-compile-failure-by-typecasting.patch \ "
SRC_URI_append_qemuall= "
file://0001-core-device.c-Change-the-default-device-timeout-to-2.patch"--
2.17.0--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
No change in PACKAGECONFIG, just default nodistro qemux86 with added systemd and debug build:DISTRO_FEATURES_append = " systemd"DEBUG_BUILD = "1"
Quoted 309 lines · Khem Raj
Quoted 9 lines · Martin Jansa
Unlike the previous version you had in your RFT branch (which added -Wno-error=format-truncation) this doesn't seem to be complete fix.
In qemux86 build which already includes this change I'm seeing:
../git/src/basic/time-util.c: In function 'format_timespan':../git/src/basic/time-util.c:508:46: error: '%0*llu' directive output between 1 and 2147483647 bytes may cause result to exceed 'INT_MAX' [-Werror=format-truncation=]Quoted 6 lines
"%s"USEC_FMT".%0*"PRI_USEC"%s",
^~~~
../git/src/basic/time-util.c:508:60: note: format string is defined here"%s"USEC_FMT".%0*"PRI_USEC"%s",
../git/src/basic/time-util.c:508:46: note: directive argument in therange
Quoted 7 lines
[0, 18446744073709551614]
"%s"USEC_FMT".%0*"PRI_USEC"%s",
^~~~And this part doesn't seem to be fixed upstream yet.
Its possible, that default config I build is not using this code. Do you enable/disable some specific packageconfig and what arch are you targetting
Quoted 12 lines
Cheers,
Quoted 9 lines · Khem Raj
Signed-off-by Khem Raj <[email protected]>--- ...ange-the-default-device-timeout-to-2.patch | 9 +- ...ation-compile-failure-by-typecasting.patch | 173 ++++++++++++++++++ meta/recipes-core/systemd/systemd_237.bb | 1 + 3 files changed, 177 insertions(+), 6 deletions(-) create mode 100644
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patchQuoted 3 lines
Quoted 3 lines
diff --git
a/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patchQuoted 1 line
Quoted 1 line
b/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patchQuoted 3 lines
Quoted 3 lines
index
b7b1ea0886..98c83620ff100644
---
a/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patchQuoted 2 lines
Quoted 2 lines
+++
b/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patchQuoted 6 lines
meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch line 4
Quoted 6 lines
meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch +1
-1@@ -1,4 +1,4 @@ -From 9820c165a9e559cf851e3beb60fad2571de4ded2 Mon Sep 17 00:00:00 2001 +From 7844e070745611a52e355b73e7890f360dd540d0 Mon Sep 17 00:00:00 2001 From: Khem Raj <[email protected]> Date: Mon, 14 Dec 2015 04:09:19 +0000 Subject: [PATCH] core/device.c: Change the default device timeout to240
Quoted 16 lines
Quoted 16 lines
sec.
meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch +2
-2@@ -16,10 +16,10 @@ Signed-off-by: Khem Raj <[email protected]> 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/device.c b/src/core/device.c -index 77601c552..98bf49ba2 100644 +index a43664d3b..4b16a8aec 100644 --- a/src/core/device.c +++ b/src/core/device.c -@@ -112,7 +112,7 @@ static void device_init(Unit *u) { +@@ -113,7 +113,7 @@ static void device_init(Unit *u) { * indefinitely for plugged in devices, something which cannot * happen for the other units since their operations time out * anyway. */@@ -28,6 +28,3 @@ index 77601c552..98bf49ba2 100644Quoted 7 lines
Quoted 7 lines
meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch +0
-3u->ignore_on_isolate = true; } --- -2.16.1 -diff --git
a/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patchQuoted 1 line
Quoted 1 line
b/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patchQuoted 5 lines
Quoted 5 lines
new file mode 100644
index 0000000000..e56061f41b
---/dev/null
+++
b/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patchQuoted 5 lines
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch line 4
Quoted 5 lines
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +4
-0@@ -0,0 +1,173 @@ +From c2b3ebe112ebfd9f9e82fb1531ee225c3152ca83 Mon Sep 17 00:00:00 2001 +From: Patrick Uiterwijk <[email protected]> +Date: Thu, 22 Feb 2018 19:41:30 +0100 +Subject: [PATCH] Fix format-truncation compile failure by typecastingUSB
Quoted 8 lines
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch
Quoted 8 lines
IDs
+ (#8250)(quoted diff) +2
-0+ +This patch adds safe_atoux16 for parsing an unsigned hexadecimal 16bitint, and
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +3
-0+uses that for parsing USB device and vendor IDs. + +This fixes a compile error with gcc-8 because while we know that USBIDs
Quoted 4 lines
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch
Quoted 4 lines
are 2 bytes,
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +3
-0+the compiler does not know that. + +../src/udev/udev-builtin-hwdb.c:80:38: error: '%04X' directive outputmay
Quoted 7 lines
Quoted 7 lines
be
+truncated writing between 4 and 8 bytes into a region of size between 2 and 6
+[-Werror=format-truncation=](quoted diff) +2
-0+ +Upstream-Status: Backport[
https://github.com/systemd/systemd/commit/5547c12503a683290eaed47954ffcfb2d1bc03cd
]Quoted 108 lines
Quoted 108 lines
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +108
-0+ +Signed-off-by: Adam Williamson <[email protected]> +Signed-off-by: Patrick Uiterwijk <[email protected]> +--- + src/basic/parse-util.c | 24 ++++++++++++++++++++++ + src/basic/parse-util.h | 2 ++ + src/test/test-parse-util.c | 39 ++++++++++++++++++++++++++++++++++++ + src/udev/udev-builtin-hwdb.c | 13 ++++++------ + 4 files changed, 71 insertions(+), 7 deletions(-) + +diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c +index 97533721d..ff3fc298a 100644 +--- a/src/basic/parse-util.c ++++ b/src/basic/parse-util.c +@@ -532,6 +532,30 @@ int safe_atoi16(const char *s, int16_t *ret) { + return 0; + } + ++int safe_atoux16(const char *s, uint16_t *ret) { ++ char *x = NULL; ++ unsigned long l; ++ ++ assert(s); ++ assert(ret); ++ ++ s += strspn(s, WHITESPACE); ++ ++ errno = 0; ++ l = strtoul(s, &x, 16); ++ if (errno > 0) ++ return -errno; ++ if (!x || x == s || *x != 0) ++ return -EINVAL; ++ if (s[0] == '-') ++ return -ERANGE; ++ if ((unsigned long) (uint16_t) l != l) ++ return -ERANGE; ++ ++ *ret = (uint16_t) l; ++ return 0; ++} ++ + int safe_atod(const char *s, double *ret_d) { + _cleanup_(freelocalep) locale_t loc = (locale_t) 0; + char *x = NULL; +diff --git a/src/basic/parse-util.h b/src/basic/parse-util.h +index 1eda1d7f9..727422056 100644 +--- a/src/basic/parse-util.h ++++ b/src/basic/parse-util.h +@@ -54,6 +54,8 @@ int safe_atou8(const char *s, uint8_t *ret); + int safe_atou16(const char *s, uint16_t *ret); + int safe_atoi16(const char *s, int16_t *ret); + ++int safe_atoux16(const char *s, uint16_t *ret); ++ + static inline int safe_atou32(const char *s, uint32_t *ret_u) { + assert_cc(sizeof(uint32_t) == sizeof(unsigned)); + return safe_atou(s, (unsigned*) ret_u); +diff --git a/src/test/test-parse-util.c b/src/test/test-parse-util.c +index 937500213..a99cea5a1 100644 +--- a/src/test/test-parse-util.c ++++ b/src/test/test-parse-util.c +@@ -468,6 +468,44 @@ static void test_safe_atoi16(void) { + assert_se(r == -EINVAL); + } + ++static void test_safe_atoux16(void) { ++ int r; ++ uint16_t l; ++ ++ r = safe_atoux16("1234", &l); ++ assert_se(r == 0); ++ assert_se(l == 0x1234); ++ ++ r = safe_atoux16("abcd", &l); ++ assert_se(r == 0); ++ assert_se(l == 0xabcd); ++ ++ r = safe_atoux16(" 1234", &l); ++ assert_se(r == 0); ++ assert_se(l == 0x1234); ++ ++ r = safe_atoux16("12345", &l); ++ assert_se(r == -ERANGE); ++ ++ r = safe_atoux16("-1", &l); ++ assert_se(r == -ERANGE); ++ ++ r = safe_atoux16(" -1", &l); ++ assert_se(r == -ERANGE); ++ ++ r = safe_atoux16("junk", &l); ++ assert_se(r == -EINVAL); ++ ++ r = safe_atoux16("123x", &l); ++ assert_se(r == -EINVAL); ++ ++ r = safe_atoux16("12.3", &l); ++ assert_se(r == -EINVAL); ++ ++ r = safe_atoux16("", &l); ++ assert_se(r == -EINVAL); ++} ++ + static void test_safe_atou64(void) { + int r; + uint64_t l; +@@ -745,6 +783,7 @@ int main(int argc, char *argv[]) {Quoted 8 lines
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch
Quoted 8 lines
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +8
-0+ test_safe_atolli(); + test_safe_atou16(); + test_safe_atoi16(); ++ test_safe_atoux16(); + test_safe_atou64(); + test_safe_atoi64(); + test_safe_atod(); +diff --git a/src/udev/udev-builtin-hwdb.c
b/src/udev/udev-builtin-hwdb.cQuoted 6 lines
Quoted 6 lines
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +6
-0+index ca7f7c230..dbfe02429 100644 +--- a/src/udev/udev-builtin-hwdb.c ++++ b/src/udev/udev-builtin-hwdb.c +@@ -27,6 +27,7 @@ + + #include "alloc-util.h"Quoted 8 lines
Quoted 8 lines
+ #include "
hwdb-util.h"
++#include "parse-util.h"
+ #include "string-util.h"
+ #include "udev-util.h"
+ #include "udev.h"
+@@ -63,7 +64,7 @@ int udev_builtin_hwdb_lookup(structudev_device*dev, +
+ static const char *modalias_usb(structudev_device*dev, char *s,
size_tQuoted 52 lines
Quoted 52 lines
size) {
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +7
-0+ const char *v, *p; +- int vn, pn; ++ uint16_t vn, pn; + + v = udev_device_get_sysattr_value(dev, "idVendor"); + if (!v) +@@ -71,12 +72,10 @@ static const char *modalias_usb(struct udev_device*dev, char *s,
size_tsize) {meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +19
-0+ p = udev_device_get_sysattr_value(dev, "idProduct"); + if (!p) + return NULL; +- vn = strtol(v, NULL, 16); +- if (vn <= 0) +- return NULL; +- pn = strtol(p, NULL, 16); +- if (pn <= 0) +- return NULL; ++ if (safe_atoux16(v, &vn) < 0) ++ return NULL; ++ if (safe_atoux16(p, &pn) < 0) ++ return NULL; + snprintf(s, size, "usb:v%04Xp%04X*", vn, pn); + return s; + } +-- +2.17.0 +meta/recipes-core/systemd/systemd_237.bb +1
-0@@ -52,6 +52,7 @@ SRC_URI += "file://touchscreen.rules \ file://0032-memfd.patch \ file://0033-basic-macros-rename-noreturn-into-_noreturn_-8456.patch \ file://libmount.patch \ + file://0034-Fix-format-truncation-compile-failure-by-typecasting.patch \ "
SRC_URI_append_qemuall= "
file://0001-core-device.c-Change-the-default-device-timeout-to-2.patch"--
2.17.0--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
It fails when -O1 or -Os is being used, builds ok with -O0, -O2, -O3.
Checking a bit more shows that it doesn't fail when -ftree-vrp is used, probably because this check is removed as the documentation for -ftree-vrp says:
-ftree-vrp
Perform Value Range Propagation on trees. This is similar to the constant propagation pass, but instead of values, ranges of values are propagated. This allows the optimizers to remove unnecessary range checks like array bound checks and null pointer checks. This is enabled by default at -O2 and higher. Null pointer check elimination is only done if -fdelete-null-pointer-checks is enabled.
Quoted 323 lines · Martin Jansa
No change in PACKAGECONFIG, just default nodistro qemux86 with added systemd and debug build:
DISTRO_FEATURES_append= " systemd"DEBUG_BUILD= "1"Quoted 314 lines · Khem Raj
Quoted 9 lines · Martin Jansa
Unlike the previous version you had in your RFT branch (which added -Wno-error=format-truncation) this doesn't seem to be complete fix.
In qemux86 build which already includes this change I'm seeing:
../git/src/basic/time-util.c: In function 'format_timespan':../git/src/basic/time-util.c:508:46: error: '%0*llu' directive output between 1 and 2147483647 bytes may cause result to exceed 'INT_MAX' [-Werror=format-truncation=]Quoted 6 lines
"%s"USEC_FMT".%0*"PRI_USEC"%s",
^~~~
../git/src/basic/time-util.c:508:60: note: format string is defined here"%s"USEC_FMT".%0*"PRI_USEC"%s",
../git/src/basic/time-util.c:508:46: note: directive argument in therange
Quoted 7 lines
[0, 18446744073709551614]
"%s"USEC_FMT".%0*"PRI_USEC"%s",
^~~~And this part doesn't seem to be fixed upstream yet.
Its possible, that default config I build is not using this code. Do you enable/disable some specific packageconfig and what arch are you targetting
Quoted 12 lines
Cheers,
Quoted 9 lines · Khem Raj
Signed-off-by Khem Raj <[email protected]>--- ...ange-the-default-device-timeout-to-2.patch | 9 +- ...ation-compile-failure-by-typecasting.patch | 173 ++++++++++++++++++ meta/recipes-core/systemd/systemd_237.bb | 1 + 3 files changed, 177 insertions(+), 6 deletions(-) create mode 100644
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patchQuoted 3 lines
Quoted 3 lines
diff --git
a/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patchQuoted 1 line
Quoted 1 line
b/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patchQuoted 3 lines
Quoted 3 lines
index
b7b1ea0886..98c83620ff100644
---
a/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patchQuoted 2 lines
Quoted 2 lines
+++
b/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patchQuoted 6 lines
meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch line 4
Quoted 6 lines
meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch +1
-1@@ -1,4 +1,4 @@ -From 9820c165a9e559cf851e3beb60fad2571de4ded2 Mon Sep 17 00:00:00 2001 +From 7844e070745611a52e355b73e7890f360dd540d0 Mon Sep 17 00:00:00 2001 From: Khem Raj <[email protected]> Date: Mon, 14 Dec 2015 04:09:19 +0000 Subject: [PATCH] core/device.c: Change the default device timeout to240
Quoted 4 lines
Quoted 4 lines
sec.
meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch +0
-0@@ -16,10 +16,10 @@ Signed-off-by: Khem Raj <[email protected]> 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 8 lines
meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch Signed-off-by: Khem Raj <[email protected]>
Quoted 8 lines
meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch +2
-2diff --git a/src/core/device.c b/src/core/device.c -index 77601c552..98bf49ba2 100644 +index a43664d3b..4b16a8aec 100644 --- a/src/core/device.c +++ b/src/core/device.c -@@ -112,7 +112,7 @@ static void device_init(Unit *u) { +@@ -113,7 +113,7 @@ static void device_init(Unit *u) { * indefinitely for plugged in devices, something whichcannot
Quoted 11 lines
Quoted 11 lines
meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch +0
-3* happen for the other units since their operations time out * anyway. */@@ -28,6 +28,3 @@ index 77601c552..98bf49ba2 100644 u->ignore_on_isolate = true; } --- -2.16.1 -diff --git
a/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patchQuoted 1 line
Quoted 1 line
b/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patchQuoted 5 lines
Quoted 5 lines
new file mode 100644
index 0000000000..e56061f41b
---/dev/null
+++
b/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patchQuoted 5 lines
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch line 4
Quoted 5 lines
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +4
-0@@ -0,0 +1,173 @@ +From c2b3ebe112ebfd9f9e82fb1531ee225c3152ca83 Mon Sep 17 00:00:00 2001 +From: Patrick Uiterwijk <[email protected]> +Date: Thu, 22 Feb 2018 19:41:30 +0100 +Subject: [PATCH] Fix format-truncation compile failure by typecastingUSB
Quoted 8 lines
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch
Quoted 8 lines
IDs
+ (#8250)(quoted diff) +2
-0+ +This patch adds safe_atoux16 for parsing an unsigned hexadecimal 16bitint, and
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +3
-0+uses that for parsing USB device and vendor IDs. + +This fixes a compile error with gcc-8 because while we know that USBIDs
Quoted 4 lines
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch
Quoted 4 lines
are 2 bytes,
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +3
-0+the compiler does not know that. + +../src/udev/udev-builtin-hwdb.c:80:38: error: '%04X' directive outputmay
Quoted 2 lines
Quoted 2 lines
be
+truncated writing between 4 and 8 bytes into a region of size between2
Quoted 5 lines
Quoted 5 lines
and 6
+[-Werror=format-truncation=](quoted diff) +2
-0+ +Upstream-Status: Backport[
https://github.com/systemd/systemd/commit/5547c12503a683290eaed47954ffcfb2d1bc03cd
]Quoted 7 lines
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch
Quoted 7 lines
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +7
-0+ +Signed-off-by: Adam Williamson <[email protected]> +Signed-off-by: Patrick Uiterwijk <[email protected]> +--- + src/basic/parse-util.c | 24 ++++++++++++++++++++++ + src/basic/parse-util.h | 2 ++ + src/test/test-parse-util.c | 39++++++++++++++++++++++++++++++++++++
Quoted 101 lines
Quoted 101 lines
+
src/udev/udev-builtin-hwdb.c| 13 ++++++------
+ 4 files changed, 71 insertions(+), 7 deletions(-)meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +99
-0+ +diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c +index 97533721d..ff3fc298a 100644 +--- a/src/basic/parse-util.c ++++ b/src/basic/parse-util.c +@@ -532,6 +532,30 @@ int safe_atoi16(const char *s, int16_t *ret) { + return 0; + } + ++int safe_atoux16(const char *s, uint16_t *ret) { ++ char *x = NULL; ++ unsigned long l; ++ ++ assert(s); ++ assert(ret); ++ ++ s += strspn(s, WHITESPACE); ++ ++ errno = 0; ++ l = strtoul(s, &x, 16); ++ if (errno > 0) ++ return -errno; ++ if (!x || x == s || *x != 0) ++ return -EINVAL; ++ if (s[0] == '-') ++ return -ERANGE; ++ if ((unsigned long) (uint16_t) l != l) ++ return -ERANGE; ++ ++ *ret = (uint16_t) l; ++ return 0; ++} ++ + int safe_atod(const char *s, double *ret_d) { + _cleanup_(freelocalep) locale_t loc = (locale_t) 0; + char *x = NULL; +diff --git a/src/basic/parse-util.h b/src/basic/parse-util.h +index 1eda1d7f9..727422056 100644 +--- a/src/basic/parse-util.h ++++ b/src/basic/parse-util.h +@@ -54,6 +54,8 @@ int safe_atou8(const char *s, uint8_t *ret); + int safe_atou16(const char *s, uint16_t *ret); + int safe_atoi16(const char *s, int16_t *ret); + ++int safe_atoux16(const char *s, uint16_t *ret); ++ + static inline int safe_atou32(const char *s, uint32_t *ret_u) { + assert_cc(sizeof(uint32_t) == sizeof(unsigned)); + return safe_atou(s, (unsigned*) ret_u); +diff --git a/src/test/test-parse-util.c b/src/test/test-parse-util.c +index 937500213..a99cea5a1 100644 +--- a/src/test/test-parse-util.c ++++ b/src/test/test-parse-util.c +@@ -468,6 +468,44 @@ static void test_safe_atoi16(void) { + assert_se(r == -EINVAL); + } + ++static void test_safe_atoux16(void) { ++ int r; ++ uint16_t l; ++ ++ r = safe_atoux16("1234", &l); ++ assert_se(r == 0); ++ assert_se(l == 0x1234); ++ ++ r = safe_atoux16("abcd", &l); ++ assert_se(r == 0); ++ assert_se(l == 0xabcd); ++ ++ r = safe_atoux16(" 1234", &l); ++ assert_se(r == 0); ++ assert_se(l == 0x1234); ++ ++ r = safe_atoux16("12345", &l); ++ assert_se(r == -ERANGE); ++ ++ r = safe_atoux16("-1", &l); ++ assert_se(r == -ERANGE); ++ ++ r = safe_atoux16(" -1", &l); ++ assert_se(r == -ERANGE); ++ ++ r = safe_atoux16("junk", &l); ++ assert_se(r == -EINVAL); ++ ++ r = safe_atoux16("123x", &l); ++ assert_se(r == -EINVAL); ++ ++ r = safe_atoux16("12.3", &l); ++ assert_se(r == -EINVAL); ++ ++ r = safe_atoux16("", &l); ++ assert_se(r == -EINVAL); ++} ++ + static void test_safe_atou64(void) { + int r; + uint64_t l; +@@ -745,6 +783,7 @@ int main(int argc, char *argv[]) {Quoted 8 lines
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch
Quoted 8 lines
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +8
-0+ test_safe_atolli(); + test_safe_atou16(); + test_safe_atoi16(); ++ test_safe_atoux16(); + test_safe_atou64(); + test_safe_atoi64(); + test_safe_atod(); +diff --git a/src/udev/udev-builtin-hwdb.c
b/src/udev/udev-builtin-hwdb.cQuoted 4 lines
Quoted 4 lines
+index
ca7f7c230..dbfe02429100644
+---a/src/udev/udev-builtin-hwdb.c
++++b/src/udev/udev-builtin-hwdb.c
+@@ -27,6 +27,7 @@Quoted 8 lines
Quoted 8 lines
+
+ #include "alloc-util.h"
+ #include "hwdb-util.h"
++#include "parse-util.h"
+ #include "string-util.h"
+ #include "udev-util.h"
+ #include "udev.h"
+@@ -63,7 +64,7 @@ int udev_builtin_hwdb_lookup(structudev_device*dev,
Quoted 2 lines
Quoted 2 lines
+
+ static const char *modalias_usb(structudev_device*dev, char *s,
size_tQuoted 36 lines
Quoted 36 lines
size) {
meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +7
-0+ const char *v, *p; +- int vn, pn; ++ uint16_t vn, pn; + + v = udev_device_get_sysattr_value(dev, "idVendor"); + if (!v) +@@ -71,12 +72,10 @@ static const char *modalias_usb(struct udev_device*dev, char *s,
size_tsize) {meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch new file +19
-0+ p = udev_device_get_sysattr_value(dev, "idProduct"); + if (!p) + return NULL; +- vn = strtol(v, NULL, 16); +- if (vn <= 0) +- return NULL; +- pn = strtol(p, NULL, 16); +- if (pn <= 0) +- return NULL; ++ if (safe_atoux16(v, &vn) < 0) ++ return NULL; ++ if (safe_atoux16(p, &pn) < 0) ++ return NULL; + snprintf(s, size, "usb:v%04Xp%04X*", vn, pn); + return s; + } +-- +2.17.0 +meta/recipes-core/systemd/systemd_237.bb +0
-0@@ -52,6 +52,7 @@ SRC_URI += "file://touchscreen.rules \ file://0032-memfd.patch \Quoted 4 lines
Quoted 4 lines
meta/recipes-core/systemd/systemd_237.bb +1
-0file://0033-basic-macros-rename-noreturn-into-_noreturn_-8456.patch \ file://libmount.patch \ +file://0034-Fix-format-truncation-compile-failure-by-typecasting.patch
\
Quoted 12 lines
Quoted 12 lines
"
SRC_URI_append_qemuall= "
file://0001-core-device.c-Change-the-default-device-timeout-to-2.patch"--
2.17.0--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Quoted 5 lines · Martin Jansa
No change in PACKAGECONFIG, just default nodistro qemux86 with added systemd and debug build:
DISTRO_FEATURES_append= " systemd"DEBUG_BUILD= "1"
hmm so must be some code which is eliminated by compiler optimizations with -O2 since with debug build it will use -O1
Quoted 337 lines
On Thu, May 31, 2018 at 6:17 PM Khem Raj <[email protected] <mailto:[email protected]>> wrote:
On Thu, May 31, 2018 at 9:05 AM, Martin Jansa <[email protected] <mailto:[email protected]>> wrote: > Unlike the previous version you had in your RFT branch (which added > -Wno-error=format-truncation) this doesn't seem to be complete fix. > > In qemux86 build which already includes this change I'm seeing: > ../git/src/basic/time-util.c: In function 'format_timespan': > ../git/src/basic/time-util.c:508:46: error: '%0*llu' directive output > between 1 and 2147483647 bytes may cause result to exceed 'INT_MAX' > [-Werror=format-truncation=] > > "%s"USEC_FMT".%0*"PRI_USEC"%s", > ^~~~ > ../git/src/basic/time-util.c:508:60: note: format string is defined here > > "%s"USEC_FMT".%0*"PRI_USEC"%s", > ../git/src/basic/time-util.c:508:46: note: directive argument in the range > [0, 18446744073709551614] > > "%s"USEC_FMT".%0*"PRI_USEC"%s", > ^~~~ > > And this part doesn't seem to be fixed upstream yet. > Its possible, that default config I build is not using this code. Do you enable/disable some specific packageconfig and what arch are you targetting > Cheers, > > On Mon, May 28, 2018 at 5:58 PM Khem Raj <[email protected] <mailto:[email protected]>> wrote: >> >> Signed-off-by: Khem Raj <[email protected] <mailto:[email protected]>> >> --- >> ...ange-the-default-device-timeout-to-2.patch | 9 +- >> ...ation-compile-failure-by-typecasting.patch | 173 ++++++++++++++++++ >> meta/recipes-core/systemd/systemd_237.bb <http://systemd_237.bb> | 1 + >> 3 files changed, 177 insertions(+), 6 deletions(-) >> create mode 100644 >> meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch >> >> 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 @@ >> -From 9820c165a9e559cf851e3beb60fad2571de4ded2 Mon Sep 17 00:00:00 2001 >> +From 7844e070745611a52e355b73e7890f360dd540d0 Mon Sep 17 00:00:00 2001 >> From: Khem Raj <[email protected] <mailto:[email protected]>> >> Date: Mon, 14 Dec 2015 04:09:19 +0000 >> Subject: [PATCH] core/device.c: Change the default device timeout to 240 >> sec. >> @@ -16,10 +16,10 @@ Signed-off-by: Khem Raj <[email protected] <mailto:[email protected]>> >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/src/core/device.c b/src/core/device.c >> -index 77601c552..98bf49ba2 100644 >> +index a43664d3b..4b16a8aec 100644 >> --- a/src/core/device.c >> +++ b/src/core/device.c >> -@@ -112,7 +112,7 @@ static void device_init(Unit *u) { >> +@@ -113,7 +113,7 @@ static void device_init(Unit *u) { >> * indefinitely for plugged in devices, something which cannot >> * happen for the other units since their operations time out >> * anyway. */ >> @@ -28,6 +28,3 @@ index 77601c552..98bf49ba2 100644 >> >> u->ignore_on_isolate = true; >> } >> --- >> -2.16.1 >> - >> 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 @@ >> +From c2b3ebe112ebfd9f9e82fb1531ee225c3152ca83 Mon Sep 17 00:00:00 2001 >> +From: Patrick Uiterwijk <[email protected] <mailto:[email protected]>> >> +Date: Thu, 22 Feb 2018 19:41:30 +0100 >> +Subject: [PATCH] Fix format-truncation compile failure by typecasting USB >> IDs >> + (#8250) >> + >> +This patch adds safe_atoux16 for parsing an unsigned hexadecimal 16bit >> int, and >> +uses that for parsing USB device and vendor IDs. >> + >> +This fixes a compile error with gcc-8 because while we know that USB IDs >> are 2 bytes, >> +the compiler does not know that. >> + >> +../src/udev/udev-builtin-hwdb.c:80:38: error: '%04X' directive output may >> be >> +truncated writing between 4 and 8 bytes into a region of size between 2 >> and 6 >> +[-Werror=format-truncation=] >> + >> +Upstream-Status: Backport >> [https://github.com/systemd/systemd/commit/5547c12503a683290eaed47954ffcfb2d1bc03cd] >> + >> +Signed-off-by: Adam Williamson <[email protected] <mailto:[email protected]>> >> +Signed-off-by: Patrick Uiterwijk <[email protected] <mailto:[email protected]>> >> +--- >> + src/basic/parse-util.c | 24 ++++++++++++++++++++++ >> + src/basic/parse-util.h | 2 ++ >> + src/test/test-parse-util.c | 39 ++++++++++++++++++++++++++++++++++++ >> + src/udev/udev-builtin-hwdb.c | 13 ++++++------ >> + 4 files changed, 71 insertions(+), 7 deletions(-) >> + >> +diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c >> +index 97533721d..ff3fc298a 100644 >> +--- a/src/basic/parse-util.c >> ++++ b/src/basic/parse-util.c >> +@@ -532,6 +532,30 @@ int safe_atoi16(const char *s, int16_t *ret) { >> + return 0; >> + } >> + >> ++int safe_atoux16(const char *s, uint16_t *ret) { >> ++ char *x = NULL; >> ++ unsigned long l; >> ++ >> ++ assert(s); >> ++ assert(ret); >> ++ >> ++ s += strspn(s, WHITESPACE); >> ++ >> ++ errno = 0; >> ++ l = strtoul(s, &x, 16); >> ++ if (errno > 0) >> ++ return -errno; >> ++ if (!x || x == s || *x != 0) >> ++ return -EINVAL; >> ++ if (s[0] == '-') >> ++ return -ERANGE; >> ++ if ((unsigned long) (uint16_t) l != l) >> ++ return -ERANGE; >> ++ >> ++ *ret = (uint16_t) l; >> ++ return 0; >> ++} >> ++ >> + int safe_atod(const char *s, double *ret_d) { >> + _cleanup_(freelocalep) locale_t loc = (locale_t) 0; >> + char *x = NULL; >> +diff --git a/src/basic/parse-util.h b/src/basic/parse-util.h >> +index 1eda1d7f9..727422056 100644 >> +--- a/src/basic/parse-util.h >> ++++ b/src/basic/parse-util.h >> +@@ -54,6 +54,8 @@ int safe_atou8(const char *s, uint8_t *ret); >> + int safe_atou16(const char *s, uint16_t *ret); >> + int safe_atoi16(const char *s, int16_t *ret); >> + >> ++int safe_atoux16(const char *s, uint16_t *ret); >> ++ >> + static inline int safe_atou32(const char *s, uint32_t *ret_u) { >> + assert_cc(sizeof(uint32_t) == sizeof(unsigned)); >> + return safe_atou(s, (unsigned*) ret_u); >> +diff --git a/src/test/test-parse-util.c b/src/test/test-parse-util.c >> +index 937500213..a99cea5a1 100644 >> +--- a/src/test/test-parse-util.c >> ++++ b/src/test/test-parse-util.c >> +@@ -468,6 +468,44 @@ static void test_safe_atoi16(void) { >> + assert_se(r == -EINVAL); >> + } >> + >> ++static void test_safe_atoux16(void) { >> ++ int r; >> ++ uint16_t l; >> ++ >> ++ r = safe_atoux16("1234", &l); >> ++ assert_se(r == 0); >> ++ assert_se(l == 0x1234); >> ++ >> ++ r = safe_atoux16("abcd", &l); >> ++ assert_se(r == 0); >> ++ assert_se(l == 0xabcd); >> ++ >> ++ r = safe_atoux16(" 1234", &l); >> ++ assert_se(r == 0); >> ++ assert_se(l == 0x1234); >> ++ >> ++ r = safe_atoux16("12345", &l); >> ++ assert_se(r == -ERANGE); >> ++ >> ++ r = safe_atoux16("-1", &l); >> ++ assert_se(r == -ERANGE); >> ++ >> ++ r = safe_atoux16(" -1", &l); >> ++ assert_se(r == -ERANGE); >> ++ >> ++ r = safe_atoux16("junk", &l); >> ++ assert_se(r == -EINVAL); >> ++ >> ++ r = safe_atoux16("123x", &l); >> ++ assert_se(r == -EINVAL); >> ++ >> ++ r = safe_atoux16("12.3", &l); >> ++ assert_se(r == -EINVAL); >> ++ >> ++ r = safe_atoux16("", &l); >> ++ assert_se(r == -EINVAL); >> ++} >> ++ >> + static void test_safe_atou64(void) { >> + int r; >> + uint64_t l; >> +@@ -745,6 +783,7 @@ int main(int argc, char *argv[]) { >> + test_safe_atolli(); >> + test_safe_atou16(); >> + test_safe_atoi16(); >> ++ test_safe_atoux16(); >> + test_safe_atou64(); >> + test_safe_atoi64(); >> + test_safe_atod(); >> +diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin-hwdb.c >> +index ca7f7c230..dbfe02429 100644 >> +--- a/src/udev/udev-builtin-hwdb.c >> ++++ b/src/udev/udev-builtin-hwdb.c >> +@@ -27,6 +27,7 @@ >> + >> + #include "alloc-util.h" >> + #include "hwdb-util.h" >> ++#include "parse-util.h" >> + #include "string-util.h" >> + #include "udev-util.h" >> + #include "udev.h" >> +@@ -63,7 +64,7 @@ int udev_builtin_hwdb_lookup(struct udev_device *dev, >> + >> + static const char *modalias_usb(struct udev_device *dev, char *s, size_t >> size) { >> + const char *v, *p; >> +- int vn, pn; >> ++ uint16_t vn, pn; >> + >> + v = udev_device_get_sysattr_value(dev, "idVendor"); >> + if (!v) >> +@@ -71,12 +72,10 @@ static const char *modalias_usb(struct udev_device >> *dev, char *s, size_t size) { >> + p = udev_device_get_sysattr_value(dev, "idProduct"); >> + if (!p) >> + return NULL; >> +- vn = strtol(v, NULL, 16); >> +- if (vn <= 0) >> +- return NULL; >> +- pn = strtol(p, NULL, 16); >> +- if (pn <= 0) >> +- return NULL; >> ++ if (safe_atoux16(v, &vn) < 0) >> ++ return NULL; >> ++ if (safe_atoux16(p, &pn) < 0) >> ++ return NULL; >> + snprintf(s, size, "usb:v%04Xp%04X*", vn, pn); >> + return s; >> + } >> +-- >> +2.17.0 >> + >> diff --git a/meta/recipes-core/systemd/systemd_237.bb <http://systemd_237.bb> >> b/meta/recipes-core/systemd/systemd_237.bb <http://systemd_237.bb> >> index b7c2113255..c4743a6b9d 100644 >> --- a/meta/recipes-core/systemd/systemd_237.bb <http://systemd_237.bb> >> +++ b/meta/recipes-core/systemd/systemd_237.bb <http://systemd_237.bb> >> @@ -52,6 +52,7 @@ SRC_URI += "file://touchscreen.rules \ >> file://0032-memfd.patch \ >> >> file://0033-basic-macros-rename-noreturn-into-_noreturn_-8456.patch \ >> file://libmount.patch \ >> + >> file://0034-Fix-format-truncation-compile-failure-by-typecasting.patch \ >> " >> SRC_URI_append_qemuall = " >> file://0001-core-device.c-Change-the-default-device-timeout-to-2.patch" >> >> -- >> 2.17.0 >> >> -- >> _______________________________________________ >> Openembedded-core mailing list >> [email protected] <mailto:[email protected]> >> http://lists.openembedded.org/mailman/listinfo/openembedded-core