package/liboping: add patch to fix gcc-8/gcc-9 snprintf truncation compile failure
PATCH 1/3 package/liboping: add patch to fix gcc-8/gcc-9 snprintf truncation compile failure
Add patch from upstream merge request ([1]) to fix fix gcc-8/gcc-9 snprintf truncation related compile failure (-Wall/-Werror), reported on the mailing list ([2]).
Fixes:
liboping.c: In function ?ping_set_ttl?:
liboping.c:207:9: error: ?%s? directive output may be truncated writing up to 255 bytes into a region of size 242 [-Werror=format-truncation=]
207 | "%s: %s", function, message);
| ^~[1] https://github.com/octo/liboping/pull/50
[2] http://lists.busybox.net/pipermail/buildroot/2020-March/275861.html
--- ...d-snprintf-truncation-warning-wError.patch | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 package/liboping/0002-Mitigated-snprintf-truncation-warning-wError.patch
package/liboping/0002-Mitigated-snprintf-truncation-warning-wError.patch new file +31 -0
@@ -0,0 +1,31 @@ +From 215003b58c9214c4a3ff5ef44f361887cdbec348 Mon Sep 17 00:00:00 2001 +From: Guillaume Picquet <[email protected]> +Date: Mon, 9 Sep 2019 17:30:47 +0200 +Subject: [PATCH] Mitigated snprintf truncation warning (-wError) + +[Upstream: https://github.com/octo/liboping/pull/50/commits/664414123a3fe89984abfa0917946c513bf47163] +Signed-off-by: Peter Seiderer <[email protected]> +--- + src/liboping.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/liboping.c b/src/liboping.c +index a2dfa19..39b0041 100644 +--- a/src/liboping.c ++++ b/src/liboping.c +@@ -203,9 +203,9 @@ static char *sstrerror (int errnum, char *buf, size_t buflen) + static void ping_set_error (pingobj_t *obj, const char *function, + const char *message) + { +- snprintf (obj->errmsg, sizeof (obj->errmsg), +- "%s: %s", function, message); +- obj->errmsg[sizeof (obj->errmsg) - 1] = 0; ++ if (snprintf (obj->errmsg, sizeof (obj->errmsg), ++ "%s: %s", function, message) >= sizeof (obj->errmsg)) ++ obj->errmsg[sizeof (obj->errmsg) - 1] = 0; + } + + static void ping_set_errno (pingobj_t *obj, int error_number) +-- +2.25.1 +
Signature · 1 line
2.25.1
PATCH 2/3 package/liboping: add patch to fix utf8 ncurses support
Add patch from upstream merge request [1] to fix fix utf8 ncurses support.
[1] https://github.com/octo/liboping/issues/36
--- package/liboping/0003-fix-utf8-support.patch | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 package/liboping/0003-fix-utf8-support.patch
package/liboping/0003-fix-utf8-support.patch new file +29 -0
@@ -0,0 +1,29 @@ +From dfbdd324769f542b6b89499c1b7f0f4322100bc6 Mon Sep 17 00:00:00 2001 +From: wfaulk <[email protected]> +Date: Wed, 7 Aug 2019 18:57:43 -0400 +Subject: [PATCH 3/4] fix utf8 support + +https://github.com/octo/liboping/issues/36 + +[Upstream: https://github.com/octo/liboping/pull/49/commits/a313923ec12d11daa8e70497c6b7b5d50965821b] +Signed-off-by: Peter Seiderer <[email protected]> +--- + src/oping.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/oping.c b/src/oping.c +index 87ca81a..62dbb67 100644 +--- a/src/oping.c ++++ b/src/oping.c +@@ -903,7 +903,7 @@ static void time_calc (struct timespec *ts_dest, /* {{{ */ + #if USE_NCURSES + static _Bool has_utf8() /* {{{ */ + { +-# if HAVE_NCURSESW_NCURSES_H ++# if HAVE_NCURSESW_CURSES_H + if (!opt_utf8) + { + /* Automatically determine */ +-- +2.25.1 +
Signature · 1 line
2.25.1
Thomas Petazzoni
AppliedRe: [Buildroot] [PATCH v1 2/3] package/liboping: add patch to fix utf8 ncurses support
Quoted 9 lines · On Fri, 6 Mar 2020 21:10:21 +0100 Peter Seiderer <[email protected]> wrote:
Add patch from upstream merge request [1] to fix fix utf8 ncurses support.
[1] https://github.com/octo/liboping/issues/36
Signed-off-by Peter Seiderer <[email protected]>--- package/liboping/0003-fix-utf8-support.patch | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 package/liboping/0003-fix-utf8-support.patch
Applied to master, thanks.
Thomas
Signature · 7 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 3/3 package/liboping: add patch to fix suid root feature
In reply to Peter SeidererAdd patch from upstream merge quest [1] to fix suid root feature.
[1] https://github.com/octo/liboping/pull/35
--- ...-when-adding-hosts-not-when-doing-th.patch | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 package/liboping/0004-Open-raw-sockets-when-adding-hosts-not-when-doing-th.patch
package/liboping/0004-Open-raw-sockets-when-adding-hosts-not-when-doing-th.patch new file +91 -0
@@ -0,0 +1,91 @@ +From ac878566eb935fd3ebfb804e6bd9e1690d4a65e3 Mon Sep 17 00:00:00 2001 +From: Tollef Fog Heen <[email protected]> +Date: Tue, 20 Mar 2018 22:40:32 +0100 +Subject: [PATCH 4/4] Open raw sockets when adding hosts, not when doing the + pinging + +This allows this to run as non-root again, without this, oping will +have dropped privileges before trying to ping, which then fails to +open the necessary raw sockets. + +Fixes: #34 + +[Upstream: https://github.com/octo/liboping/pull/35/commits/a88c51f38dafa1fba9118045176754bec05d3c94] +Signed-off-by: Peter Seiderer <[email protected]> +--- + src/liboping.c | 48 +++++++++++++++++------------------------------- + 1 file changed, 17 insertions(+), 31 deletions(-) + +diff --git a/src/liboping.c b/src/liboping.c +index 39b0041..f98e810 100644 +--- a/src/liboping.c ++++ b/src/liboping.c +@@ -1344,41 +1344,10 @@ int ping_send (pingobj_t *obj) + struct timeval nowtime; + struct timeval timeout; + +- _Bool need_ipv4_socket = 0; +- _Bool need_ipv6_socket = 0; +- + for (ptr = obj->head; ptr != NULL; ptr = ptr->next) + { + ptr->latency = -1.0; + ptr->recv_ttl = -1; +- +- if (ptr->addrfamily == AF_INET) +- need_ipv4_socket = 1; +- else if (ptr->addrfamily == AF_INET6) +- need_ipv6_socket = 1; +- } +- +- if (!need_ipv4_socket && !need_ipv6_socket) +- { +- ping_set_error (obj, "ping_send", "No hosts to ping"); +- return (-1); +- } +- +- if (need_ipv4_socket && obj->fd4 == -1) +- { +- obj->fd4 = ping_open_socket(obj, AF_INET); +- if (obj->fd4 == -1) +- return (-1); +- ping_set_ttl (obj, obj->ttl); +- ping_set_qos (obj, obj->qos); +- } +- if (need_ipv6_socket && obj->fd6 == -1) +- { +- obj->fd6 = ping_open_socket(obj, AF_INET6); +- if (obj->fd6 == -1) +- return (-1); +- ping_set_ttl (obj, obj->ttl); +- ping_set_qos (obj, obj->qos); + } + + if (gettimeofday (&nowtime, NULL) == -1) +@@ -1698,6 +1667,23 @@ int ping_host_add (pingobj_t *obj, const char *host) + ph->table_next = obj->table[ph->ident % PING_TABLE_LEN]; + obj->table[ph->ident % PING_TABLE_LEN] = ph; + ++ if (ph->addrfamily == AF_INET && obj->fd4 == -1) ++ { ++ obj->fd4 = ping_open_socket(obj, AF_INET); ++ if (obj->fd4 == -1) ++ return (-1); ++ ping_set_ttl (obj, obj->ttl); ++ ping_set_qos (obj, obj->qos); ++ } ++ if (ph->addrfamily == AF_INET6 && obj->fd6 == -1) ++ { ++ obj->fd6 = ping_open_socket(obj, AF_INET6); ++ if (obj->fd6 == -1) ++ return (-1); ++ ping_set_ttl (obj, obj->ttl); ++ ping_set_qos (obj, obj->qos); ++ } ++ + return (0); + } /* int ping_host_add */ + +-- +2.25.1 +
Signature · 1 line
2.25.1
Thomas Petazzoni
AppliedRe: [Buildroot] [PATCH v1 3/3] package/liboping: add patch to fix suid root feature
Quoted 9 lines · On Fri, 6 Mar 2020 21:10:22 +0100 Peter Seiderer <[email protected]> wrote:
Add patch from upstream merge quest [1] to fix suid root feature.
[1] https://github.com/octo/liboping/pull/35
Signed-off-by Peter Seiderer <[email protected]>--- ...-when-adding-hosts-not-when-doing-th.patch | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 package/liboping/0004-Open-raw-sockets-when-adding-hosts-not-when-doing-th.patch
Applied to master, thanks.
Thomas
Signature · 7 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 1/3 package/liboping: add patch to fix gcc-8/gcc-9 snprintf truncation compile failure
In reply to Peter SeidererHello Peter,
Quoted 8 lines · On Fri, 6 Mar 2020 21:10:20 +0100 Peter Seiderer <[email protected]> wrote:
Add patch from upstream merge request ([1]) to fix fix gcc-8/gcc-9 snprintf truncation related compile failure (-Wall/-Werror), reported on the mailing list ([2]).
Fixes:
liboping.c: In function ?ping_set_ttl?:
liboping.c:207:9: error: ?%s? directive output may be truncated writing up to 255 bytes into a region of size 242 [-Werror=format-truncation=]
Quoted 8 lines
207 | "%s: %s", function, message); | ^~[1] https://github.com/octo/liboping/pull/50
[2] http://lists.busybox.net/pipermail/buildroot/2020-March/275861.htmlReported-by Maik Brenke <[email protected]>Signed-off-by Peter Seiderer <[email protected]>
This build issue has happened once in the autobuilders:
http://autobuild.buildroot.net/results/b12/b12d86388b495a96194e0bcbb5c19a4e35cbc53d/build-end.log
But liboping has been built successfully zillions of times:
http://autobuild.buildroot.net/index.php?symbols%5BBR2_PACKAGE_LIBOPING%5D=y
Why is it that we don't see this build failure ?
Also, this build failure was reported at
https://github.com/octo/liboping/issues/38, and the upstream developer says it has been fixed by
https://github.com/octo/liboping/commit/18ca43507b351f339ff23062541ee8d58e813a53,
which is different from your patch.
Could you clarify this ?
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 1/3 package/liboping: add patch to fix gcc-8/gcc-9 snprintf truncation compile failure
Hello Thomas,
Quoted 24 lines · Thomas Petazzoni
Hello Peter,
Quoted 8 lines · On Fri, 6 Mar 2020 21:10:20 +0100 Peter Seiderer <[email protected]> wrote:
Add patch from upstream merge request ([1]) to fix fix gcc-8/gcc-9 snprintf truncation related compile failure (-Wall/-Werror), reported on the mailing list ([2]).
Fixes:
liboping.c: In function ?ping_set_ttl?:
liboping.c:207:9: error: ?%s? directive output may be truncated writing up to 255 bytes into a region of size 242 [-Werror=format-truncation=]Quoted 8 lines
207 | "%s: %s", function, message); | ^~[1] https://github.com/octo/liboping/pull/50
[2] http://lists.busybox.net/pipermail/buildroot/2020-March/275861.htmlReported-by Maik Brenke <[email protected]>Signed-off-by Peter Seiderer <[email protected]>This build issue has happened once in the autobuilders:
Quoted 7 lines
http://autobuild.buildroot.net/results/b12/b12d86388b495a96194e0bcbb5c19a4e35cbc53d/build-end.log
But liboping has been built successfully zillions of times:
http://autobuild.buildroot.net/index.php?symbols%5BBR2_PACKAGE_LIBOPING%5D=y
Why is it that we don't see this build failure ?
Don't know...but could reproduce it with the buildroot toolchain for raspberry pi and gcc-9.2.0 and the original reporter used fs-toolchain-8.3-armv7ahf (maybe a gcc-8.3 one)?
Quoted 6 lines
Also, this build failure was reported at
https://github.com/octo/liboping/issues/38, and the upstream developer says it has been fixed by
https://github.com/octo/liboping/commit/18ca43507b351f339ff23062541ee8d58e813a53,
which is different from your patch.
This patch is part of buildroot since commit [3]...,
and fixes it at location line 1636ff, the new patch fixes a similar failure, but not the same... at line 203ff...
Quoted 3 lines
Could you clarify this ?
Maybe ;-)
Regards,
Peter
[3] https://git.buildroot.net/buildroot/commit/?id=8361c53eac06a8a96fd029e31ca7119e218e1e3e
Quoted 1 line
Thomas
Hello Peter,
Quoted 14 lines · On Fri, 6 Mar 2020 21:10:20 +0100 Peter Seiderer <[email protected]> wrote:
Add patch from upstream merge request ([1]) to fix fix gcc-8/gcc-9 snprintf truncation related compile failure (-Wall/-Werror), reported on the mailing list ([2]).
Fixes:
liboping.c: In function ‘ping_set_ttl’:
liboping.c:207:9: error: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 242 [-Werror=format-truncation=]207 | "%s: %s", function, message); | ^~[1] https://github.com/octo/liboping/pull/50
[2] http://lists.busybox.net/pipermail/buildroot/2020-March/275861.html
Quoted 6 lines
Reported-by Maik Brenke <[email protected]>Signed-off-by Peter Seiderer <[email protected]>--- ...d-snprintf-truncation-warning-wError.patch | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 package/liboping/0002-Mitigated-snprintf-truncation-warning-wError.patch
So I'm sorry, but the problem still didn't occur. I've tried using gcc 8.x and 9.x toolchains, haven't been able to see, and neither were the autobuilders.
So for now, I'll mark this patch as Rejected, but if you have a reproducer, we can certainly reconsider this.
Best regards,
Thomas
Signature · 7 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Thomas,
Quoted 26 lines · Thomas Petazzoni
Hello Peter,
Quoted 14 lines · On Fri, 6 Mar 2020 21:10:20 +0100 Peter Seiderer <[email protected]> wrote:
Add patch from upstream merge request ([1]) to fix fix gcc-8/gcc-9 snprintf truncation related compile failure (-Wall/-Werror), reported on the mailing list ([2]).
Fixes:
liboping.c: In function ‘ping_set_ttl’:
liboping.c:207:9: error: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 242 [-Werror=format-truncation=]207 | "%s: %s", function, message); | ^~[1] https://github.com/octo/liboping/pull/50
[2] http://lists.busybox.net/pipermail/buildroot/2020-March/275861.htmlQuoted 6 lines
Reported-by Maik Brenke <[email protected]>Signed-off-by Peter Seiderer <[email protected]>--- ...d-snprintf-truncation-warning-wError.patch | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 package/liboping/0002-Mitigated-snprintf-truncation-warning-wError.patch
Quoted 6 lines
So I'm sorry, but the problem still didn't occur. I've tried using gcc 8.x and 9.x toolchains, haven't been able to see, and neither were the autobuilders.
So for now, I'll mark this patch as Rejected, but if you have a reproducer, we can certainly reconsider this.
Still reproducible with the following defconfig:
BR2_arm=y
BR2_arm1176jzf_s=y
BR2_OPTIMIZE_3=y
BR2_FORTIFY_SOURCE_NONE=y
BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
BR2_GCC_VERSION_9_X=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_PACKAGE_LIBOPING=y
Regards,
Peter
Quoted 4 lines
Best regards,
Thomas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot