linma / rpms / iproute

Forked from rpms/iproute 4 years ago
Clone

Blame SOURCES/0061-Use-libbsd-for-strlcpy-if-available.patch

8def76
From d3153cc39f5dca57e2cfc2faaefc690f64af398f Mon Sep 17 00:00:00 2001
8def76
From: Andrea Claudi <aclaudi@redhat.com>
8def76
Date: Thu, 13 Jun 2019 14:37:57 +0200
8def76
Subject: [PATCH] Use libbsd for strlcpy if available
8def76
8def76
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1716361
8def76
Upstream Status: iproute2.git commit 508f3c231efb1
8def76
8def76
commit 508f3c231efb179fb842d222e8151b395937b136
8def76
Author: Luca Boccassi <bluca@debian.org>
8def76
Date:   Wed Oct 31 18:00:11 2018 +0000
8def76
8def76
    Use libbsd for strlcpy if available
8def76
8def76
    If libc does not provide strlcpy check for libbsd with pkg-config to
8def76
    avoid relying on inline version.
8def76
8def76
    Signed-off-by: Luca Boccassi <bluca@debian.org>
8def76
    Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
8def76
---
8def76
 configure             | 11 +++++++++--
8def76
 genl/ctrl.c           |  3 +++
8def76
 ip/iplink.c           |  3 +++
8def76
 ip/ipnetns.c          |  3 +++
8def76
 ip/iproute_lwtunnel.c |  3 +++
8def76
 ip/ipvrf.c            |  3 +++
8def76
 ip/ipxfrm.c           |  3 +++
8def76
 ip/tunnel.c           |  3 +++
8def76
 ip/xfrm_state.c       |  3 +++
8def76
 lib/bpf.c             |  3 +++
8def76
 lib/fs.c              |  3 +++
8def76
 lib/inet_proto.c      |  3 +++
8def76
 misc/ss.c             |  3 +++
8def76
 tc/em_ipset.c         |  3 +++
8def76
 tc/m_pedit.c          |  3 +++
8def76
 15 files changed, 51 insertions(+), 2 deletions(-)
8def76
8def76
diff --git a/configure b/configure
8def76
index 5ef5cd4cf9cde..07c18f9bda4a2 100755
8def76
--- a/configure
8def76
+++ b/configure
8def76
@@ -330,8 +330,15 @@ EOF
8def76
     then
8def76
 	echo "no"
8def76
     else
8def76
-	echo 'CFLAGS += -DNEED_STRLCPY' >>$CONFIG
8def76
-	echo "yes"
8def76
+	if ${PKG_CONFIG} libbsd --exists
8def76
+	then
8def76
+		echo 'CFLAGS += -DHAVE_LIBBSD' `${PKG_CONFIG} libbsd --cflags` >>$CONFIG
8def76
+		echo 'LDLIBS +=' `${PKG_CONFIG} libbsd --libs` >> $CONFIG
8def76
+		echo "no"
8def76
+	else
8def76
+		echo 'CFLAGS += -DNEED_STRLCPY' >>$CONFIG
8def76
+		echo "yes"
8def76
+	fi
8def76
     fi
8def76
     rm -f $TMPDIR/strtest.c $TMPDIR/strtest
8def76
 }
8def76
diff --git a/genl/ctrl.c b/genl/ctrl.c
8def76
index 0d9c5f2517b78..4063ec0ba474b 100644
8def76
--- a/genl/ctrl.c
8def76
+++ b/genl/ctrl.c
8def76
@@ -18,6 +18,9 @@
8def76
 #include <netinet/in.h>
8def76
 #include <arpa/inet.h>
8def76
 #include <string.h>
8def76
+#ifdef HAVE_LIBBSD
8def76
+#include <bsd/string.h>
8def76
+#endif
8def76
 
8def76
 #include "utils.h"
8def76
 #include "genl_utils.h"
8def76
diff --git a/ip/iplink.c b/ip/iplink.c
8def76
index 0ba5f1af76697..2f8f3bf1f84bb 100644
8def76
--- a/ip/iplink.c
8def76
+++ b/ip/iplink.c
8def76
@@ -24,6 +24,9 @@
8def76
 #include <netinet/in.h>
8def76
 #include <arpa/inet.h>
8def76
 #include <string.h>
8def76
+#ifdef HAVE_LIBBSD
8def76
+#include <bsd/string.h>
8def76
+#endif
8def76
 #include <sys/ioctl.h>
8def76
 #include <stdbool.h>
8def76
 #include <linux/mpls.h>
8def76
diff --git a/ip/ipnetns.c b/ip/ipnetns.c
8def76
index 368be0cbc0a48..5991592e947b6 100644
8def76
--- a/ip/ipnetns.c
8def76
+++ b/ip/ipnetns.c
8def76
@@ -8,6 +8,9 @@
8def76
 #include <sys/syscall.h>
8def76
 #include <stdio.h>
8def76
 #include <string.h>
8def76
+#ifdef HAVE_LIBBSD
8def76
+#include <bsd/string.h>
8def76
+#endif
8def76
 #include <sched.h>
8def76
 #include <fcntl.h>
8def76
 #include <dirent.h>
8def76
diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
8def76
index 388cd19a3ef0b..be9f60c3b2137 100644
8def76
--- a/ip/iproute_lwtunnel.c
8def76
+++ b/ip/iproute_lwtunnel.c
8def76
@@ -16,6 +16,9 @@
8def76
 #include <unistd.h>
8def76
 #include <fcntl.h>
8def76
 #include <string.h>
8def76
+#ifdef HAVE_LIBBSD
8def76
+#include <bsd/string.h>
8def76
+#endif
8def76
 #include <linux/ila.h>
8def76
 #include <linux/lwtunnel.h>
8def76
 #include <linux/mpls_iptunnel.h>
8def76
diff --git a/ip/ipvrf.c b/ip/ipvrf.c
8def76
index 8a6b7f977b142..8572b4f23e3dc 100644
8def76
--- a/ip/ipvrf.c
8def76
+++ b/ip/ipvrf.c
8def76
@@ -21,6 +21,9 @@
8def76
 #include <stdlib.h>
8def76
 #include <unistd.h>
8def76
 #include <string.h>
8def76
+#ifdef HAVE_LIBBSD
8def76
+#include <bsd/string.h>
8def76
+#endif
8def76
 #include <dirent.h>
8def76
 #include <errno.h>
8def76
 #include <limits.h>
8def76
diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c
8def76
index 12c2f721571b6..5304dfc1af906 100644
8def76
--- a/ip/ipxfrm.c
8def76
+++ b/ip/ipxfrm.c
8def76
@@ -28,6 +28,9 @@
8def76
 #include <stdio.h>
8def76
 #include <stdlib.h>
8def76
 #include <string.h>
8def76
+#ifdef HAVE_LIBBSD
8def76
+#include <bsd/string.h>
8def76
+#endif
8def76
 #include <sys/types.h>
8def76
 #include <sys/socket.h>
8def76
 #include <time.h>
8def76
diff --git a/ip/tunnel.c b/ip/tunnel.c
8def76
index 79de7f2406f0e..d54505d483d22 100644
8def76
--- a/ip/tunnel.c
8def76
+++ b/ip/tunnel.c
8def76
@@ -24,6 +24,9 @@
8def76
 
8def76
 #include <stdio.h>
8def76
 #include <string.h>
8def76
+#ifdef HAVE_LIBBSD
8def76
+#include <bsd/string.h>
8def76
+#endif
8def76
 #include <unistd.h>
8def76
 #include <errno.h>
8def76
 #include <sys/types.h>
8def76
diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
8def76
index 85d959cc4f44f..0c8df7e6e10cd 100644
8def76
--- a/ip/xfrm_state.c
8def76
+++ b/ip/xfrm_state.c
8def76
@@ -27,6 +27,9 @@
8def76
 #include <stdio.h>
8def76
 #include <stdlib.h>
8def76
 #include <string.h>
8def76
+#ifdef HAVE_LIBBSD
8def76
+#include <bsd/string.h>
8def76
+#endif
8def76
 #include <netdb.h>
8def76
 #include "utils.h"
8def76
 #include "xfrm.h"
8def76
diff --git a/lib/bpf.c b/lib/bpf.c
8def76
index 45f279fa4a416..35d7c45a2924d 100644
8def76
--- a/lib/bpf.c
8def76
+++ b/lib/bpf.c
8def76
@@ -15,6 +15,9 @@
8def76
 #include <stdlib.h>
8def76
 #include <unistd.h>
8def76
 #include <string.h>
8def76
+#ifdef HAVE_LIBBSD
8def76
+#include <bsd/string.h>
8def76
+#endif
8def76
 #include <stdbool.h>
8def76
 #include <stdint.h>
8def76
 #include <errno.h>
8def76
diff --git a/lib/fs.c b/lib/fs.c
8def76
index 86efd4ed2ed80..af36bea0987fa 100644
8def76
--- a/lib/fs.c
8def76
+++ b/lib/fs.c
8def76
@@ -20,6 +20,9 @@
8def76
 #include <stdlib.h>
8def76
 #include <unistd.h>
8def76
 #include <string.h>
8def76
+#ifdef HAVE_LIBBSD
8def76
+#include <bsd/string.h>
8def76
+#endif
8def76
 #include <errno.h>
8def76
 #include <limits.h>
8def76
 
8def76
diff --git a/lib/inet_proto.c b/lib/inet_proto.c
8def76
index 0836a4c96a0b4..b379d8f8e720e 100644
8def76
--- a/lib/inet_proto.c
8def76
+++ b/lib/inet_proto.c
8def76
@@ -18,6 +18,9 @@
8def76
 #include <netinet/in.h>
8def76
 #include <netdb.h>
8def76
 #include <string.h>
8def76
+#ifdef HAVE_LIBBSD
8def76
+#include <bsd/string.h>
8def76
+#endif
8def76
 
8def76
 #include "rt_names.h"
8def76
 #include "utils.h"
8def76
diff --git a/misc/ss.c b/misc/ss.c
8def76
index 41e7762bb61f5..7e94f2c8d1baa 100644
8def76
--- a/misc/ss.c
8def76
+++ b/misc/ss.c
8def76
@@ -18,6 +18,9 @@
8def76
 #include <sys/uio.h>
8def76
 #include <netinet/in.h>
8def76
 #include <string.h>
8def76
+#ifdef HAVE_LIBBSD
8def76
+#include <bsd/string.h>
8def76
+#endif
8def76
 #include <errno.h>
8def76
 #include <netdb.h>
8def76
 #include <arpa/inet.h>
8def76
diff --git a/tc/em_ipset.c b/tc/em_ipset.c
8def76
index 48b287f5ba3b2..550b2101a0579 100644
8def76
--- a/tc/em_ipset.c
8def76
+++ b/tc/em_ipset.c
8def76
@@ -20,6 +20,9 @@
8def76
 #include <netdb.h>
8def76
 #include <unistd.h>
8def76
 #include <string.h>
8def76
+#ifdef HAVE_LIBBSD
8def76
+#include <bsd/string.h>
8def76
+#endif
8def76
 #include <stdlib.h>
8def76
 #include <getopt.h>
8def76
 
8def76
diff --git a/tc/m_pedit.c b/tc/m_pedit.c
8def76
index 2aeb56d9615f1..baacc80dd94b7 100644
8def76
--- a/tc/m_pedit.c
8def76
+++ b/tc/m_pedit.c
8def76
@@ -23,6 +23,9 @@
8def76
 #include <netinet/in.h>
8def76
 #include <arpa/inet.h>
8def76
 #include <string.h>
8def76
+#ifdef HAVE_LIBBSD
8def76
+#include <bsd/string.h>
8def76
+#endif
8def76
 #include <dlfcn.h>
8def76
 #include "utils.h"
8def76
 #include "tc_util.h"
8def76
-- 
8def76
2.20.1
8def76