All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [git commit] package/liboping: fix build with gcc >= 7
@ 2022-04-21 17:32 Arnout Vandecappelle
  0 siblings, 0 replies; only message in thread
From: Arnout Vandecappelle @ 2022-04-21 17:32 UTC (permalink / raw)
  To: buildroot

commit: https://git.buildroot.net/buildroot/commit/?id=1b47bd987f9d549b3dc5d7127d1773275560196d
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

Replace first patch (which is not in master after nearly 4 years) with
a new set of pending patches to fix the following build failure with
gcc >= 7:

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);
      |         ^~
......
  829 |      sstrerror (ret, errbuf, sizeof (errbuf)));
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
liboping.c:206:2: note: 'snprintf' output between 15 and 270 bytes into a destination of size 256
  206 |  snprintf (obj->errmsg, sizeof (obj->errmsg),
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  207 |    "%s: %s", function, message);
      |    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fixes:
 - http://autobuild.buildroot.org/results/31083354e9064b2deef86917d67e92a88af0fa46

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
 ...8-support.patch => 0001-fix-utf8-support.patch} |  0
 ...size-to-make-GCC-s-truncation-check-happy.patch | 31 ---------------------
 ...kets-when-adding-hosts-not-when-doing-th.patch} |  0
 ...-with-GCC-7-buffer-overflow-with-snprintf.patch | 28 +++++++++++++++++++
 .../liboping/0004-Fix-compile-error-on-GCC-7.patch | 32 ++++++++++++++++++++++
 5 files changed, 60 insertions(+), 31 deletions(-)

diff --git a/package/liboping/0002-fix-utf8-support.patch b/package/liboping/0001-fix-utf8-support.patch
similarity index 100%
rename from package/liboping/0002-fix-utf8-support.patch
rename to package/liboping/0001-fix-utf8-support.patch
diff --git a/package/liboping/0001-ping_host_add-Decrease-buffer-size-to-make-GCC-s-truncation-check-happy.patch b/package/liboping/0001-ping_host_add-Decrease-buffer-size-to-make-GCC-s-truncation-check-happy.patch
deleted file mode 100644
index b0aca8a715..0000000000
--- a/package/liboping/0001-ping_host_add-Decrease-buffer-size-to-make-GCC-s-truncation-check-happy.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From 18ca43507b351f339ff23062541ee8d58e813a53 Mon Sep 17 00:00:00 2001
-From: Florian Forster <ff@octo.it>
-Date: Sun, 29 Jul 2018 14:34:19 +0200
-Subject: [PATCH] ping_host_add: Decrease buffer size to make GCC's truncation
- check happy.
-
-Fixes: #38
-Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
-[Retrieved from:
-https://github.com/octo/liboping/commit/18ca43507b351f339ff23062541ee8d58e813a53]
----
- src/liboping.c | 6 ++----
- 1 file changed, 2 insertions(+), 4 deletions(-)
-
-diff --git a/src/liboping.c b/src/liboping.c
-index 5253e8c..2470988 100644
---- a/src/liboping.c
-+++ b/src/liboping.c
-@@ -1636,10 +1636,8 @@ int ping_host_add (pingobj_t *obj, const char *host)
- 		}
- 		else
- 		{
--			char errmsg[PING_ERRMSG_LEN];
--
--			snprintf (errmsg, PING_ERRMSG_LEN, "Unknown `ai_family': %i", ai_ptr->ai_family);
--			errmsg[PING_ERRMSG_LEN - 1] = '\0';
-+			char errmsg[64];
-+			snprintf (errmsg, sizeof(errmsg), "Unknown `ai_family': %d", ai_ptr->ai_family);
- 
- 			dprintf ("%s", errmsg);
- 			ping_set_error (obj, "getaddrinfo", errmsg);
diff --git a/package/liboping/0003-Open-raw-sockets-when-adding-hosts-not-when-doing-th.patch b/package/liboping/0002-Open-raw-sockets-when-adding-hosts-not-when-doing-th.patch
similarity index 100%
rename from package/liboping/0003-Open-raw-sockets-when-adding-hosts-not-when-doing-th.patch
rename to package/liboping/0002-Open-raw-sockets-when-adding-hosts-not-when-doing-th.patch
diff --git a/package/liboping/0003-Fix-compile-break-with-GCC-7-buffer-overflow-with-snprintf.patch b/package/liboping/0003-Fix-compile-break-with-GCC-7-buffer-overflow-with-snprintf.patch
new file mode 100644
index 0000000000..546f159187
--- /dev/null
+++ b/package/liboping/0003-Fix-compile-break-with-GCC-7-buffer-overflow-with-snprintf.patch
@@ -0,0 +1,28 @@
+From 0ad9ee080a7cd8037c341067cc67a84e32e69fea Mon Sep 17 00:00:00 2001
+From: Maurice Smulders <Maurice.Smulders@windtalker.com>
+Date: Thu, 30 Dec 2021 10:45:42 -0700
+Subject: [PATCH] Fix compile break with GCC 7+ - buffer overflow with snprintf
+
+[Retrieved from:
+https://github.com/octo/liboping/pull/64/commits/0ad9ee080a7cd8037c341067cc67a84e32e69fea]
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+---
+ src/liboping.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/liboping.c b/src/liboping.c
+index bf9e059..9fd8f53 100644
+--- a/src/liboping.c
++++ b/src/liboping.c
+@@ -203,8 +203,11 @@ static char *sstrerror (int errnum, char *buf, size_t buflen)
+ static void ping_set_error (pingobj_t *obj, const char *function,
+ 	       	const char *message)
+ {
++#pragma GCC diagnostic push
++#pragma GCC diagnostic ignored "-Wformat-truncation"
+ 	snprintf (obj->errmsg, sizeof (obj->errmsg),
+ 			"%s: %s", function, message);
++#pragma GCC diagnostic pop
+ 	obj->errmsg[sizeof (obj->errmsg) - 1] = 0;
+ }
+ 
diff --git a/package/liboping/0004-Fix-compile-error-on-GCC-7.patch b/package/liboping/0004-Fix-compile-error-on-GCC-7.patch
new file mode 100644
index 0000000000..38355be40e
--- /dev/null
+++ b/package/liboping/0004-Fix-compile-error-on-GCC-7.patch
@@ -0,0 +1,32 @@
+From 3d685bdb1a6c655bce6d36cfd96e084be07cd2b1 Mon Sep 17 00:00:00 2001
+From: Maurice Smulders <Maurice.Smulders@windtalker.com>
+Date: Tue, 4 Jan 2022 12:49:36 -0700
+Subject: [PATCH] Fix compile error on GCC < 7
+
+[Retrieved from:
+https://github.com/octo/liboping/pull/64/commits/3d685bdb1a6c655bce6d36cfd96e084be07cd2b1]
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+---
+ src/liboping.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/liboping.c b/src/liboping.c
+index 9fd8f53..1ccf609 100644
+--- a/src/liboping.c
++++ b/src/liboping.c
+@@ -203,11 +203,15 @@ static char *sstrerror (int errnum, char *buf, size_t buflen)
+ static void ping_set_error (pingobj_t *obj, const char *function,
+ 	       	const char *message)
+ {
++#if __GNUC__ >= 7
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wformat-truncation"
++#endif
+ 	snprintf (obj->errmsg, sizeof (obj->errmsg),
+ 			"%s: %s", function, message);
++#if __GNUC__ >= 7
+ #pragma GCC diagnostic pop
++#endif
+ 	obj->errmsg[sizeof (obj->errmsg) - 1] = 0;
+ }
+ 
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-21 18:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 17:32 [Buildroot] [git commit] package/liboping: fix build with gcc >= 7 Arnout Vandecappelle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.