]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
Use libbsd for strlcpy if available
authorLuca Boccassi <bluca@debian.org>
Wed, 31 Oct 2018 18:00:11 +0000 (18:00 +0000)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 1 Nov 2018 19:47:03 +0000 (12:47 -0700)
If libc does not provide strlcpy check for libbsd with pkg-config to
avoid relying on inline version.

Signed-off-by: Luca Boccassi <bluca@debian.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
15 files changed:
configure
genl/ctrl.c
ip/iplink.c
ip/ipnetns.c
ip/iproute_lwtunnel.c
ip/ipvrf.c
ip/ipxfrm.c
ip/tunnel.c
ip/xfrm_state.c
lib/bpf.c
lib/fs.c
lib/inet_proto.c
misc/ss.c
tc/em_ipset.c
tc/m_pedit.c

index 744d6282a926a1eb289a9a90e7f9765e2419ec31..c5655978ec3f20b9fc1f775709b9be9fee801072 100755 (executable)
--- a/configure
+++ b/configure
@@ -330,8 +330,15 @@ EOF
     then
        echo "no"
     else
-       echo 'CFLAGS += -DNEED_STRLCPY' >>$CONFIG
-       echo "yes"
+       if ${PKG_CONFIG} libbsd --exists
+       then
+               echo 'CFLAGS += -DHAVE_LIBBSD' `${PKG_CONFIG} libbsd --cflags` >>$CONFIG
+               echo 'LDLIBS +=' `${PKG_CONFIG} libbsd --libs` >> $CONFIG
+               echo "no"
+       else
+               echo 'CFLAGS += -DNEED_STRLCPY' >>$CONFIG
+               echo "yes"
+       fi
     fi
     rm -f $TMPDIR/strtest.c $TMPDIR/strtest
 }
index 6133336ab435539de0df6228a47a8a3086ed40f6..fef6aaa9c0195a22d45cca6c98f6764e656075b3 100644 (file)
@@ -18,6 +18,9 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <string.h>
+#ifdef HAVE_LIBBSD
+#include <bsd/string.h>
+#endif
 
 #include "utils.h"
 #include "genl_utils.h"
index b5519201fef7d6e1a920af3e9d3d6c8c1be1c23e..067f5409e569ef42c75711d1c78526e1f036452d 100644 (file)
@@ -24,6 +24,9 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <string.h>
+#ifdef HAVE_LIBBSD
+#include <bsd/string.h>
+#endif
 #include <sys/ioctl.h>
 #include <stdbool.h>
 #include <linux/mpls.h>
index 0eac18cf268234cb242280c0c1fc4f3347831f1c..da019d76202294acba5dbfb42ac9462b1f4738f6 100644 (file)
@@ -8,6 +8,9 @@
 #include <sys/syscall.h>
 #include <stdio.h>
 #include <string.h>
+#ifdef HAVE_LIBBSD
+#include <bsd/string.h>
+#endif
 #include <sched.h>
 #include <fcntl.h>
 #include <dirent.h>
index 8f49701509d204bdea966d30c4006cbb7964d772..2285bc1d5e31eab22a6fbef739ff8e6abfd53292 100644 (file)
@@ -16,6 +16,9 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <string.h>
+#ifdef HAVE_LIBBSD
+#include <bsd/string.h>
+#endif
 #include <linux/ila.h>
 #include <linux/lwtunnel.h>
 #include <linux/mpls_iptunnel.h>
index 8a6b7f977b1423da8c1ee0df8379d90ba4716cc0..8572b4f23e3dc494853e9468a5ce2f1bc14f72d5 100644 (file)
@@ -21,6 +21,9 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
+#ifdef HAVE_LIBBSD
+#include <bsd/string.h>
+#endif
 #include <dirent.h>
 #include <errno.h>
 #include <limits.h>
index 17ab4abef4be5c66875e47e69080f407e0d1cd5d..b02f30a65f636e937205c559bc8e9e03b006a85b 100644 (file)
@@ -28,6 +28,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef HAVE_LIBBSD
+#include <bsd/string.h>
+#endif
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <time.h>
index d0d55f37169e9f522e39453b894b61f9bbf0200e..73abb2e272e144f6334059c19c6741f031cdc88f 100644 (file)
@@ -24,6 +24,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#ifdef HAVE_LIBBSD
+#include <bsd/string.h>
+#endif
 #include <unistd.h>
 #include <errno.h>
 #include <sys/types.h>
index e8c0174629161db1f43a6ee0304740bd7cf507c9..18e0c6fa6a578485cc9f6268279938147c804c36 100644 (file)
@@ -27,6 +27,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef HAVE_LIBBSD
+#include <bsd/string.h>
+#endif
 #include <netdb.h>
 #include "utils.h"
 #include "xfrm.h"
index 45f279fa4a416a52d3131b3ffe407ae2a9562d47..35d7c45a2924d9644f123fbc4eeebd7fe31bf763 100644 (file)
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -15,6 +15,9 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
+#ifdef HAVE_LIBBSD
+#include <bsd/string.h>
+#endif
 #include <stdbool.h>
 #include <stdint.h>
 #include <errno.h>
index 86efd4ed2ed8084ad147b5d53e62ac2458ccf289..af36bea0987fa97f2452d71b5db9f1c81be650d1 100644 (file)
--- a/lib/fs.c
+++ b/lib/fs.c
@@ -20,6 +20,9 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
+#ifdef HAVE_LIBBSD
+#include <bsd/string.h>
+#endif
 #include <errno.h>
 #include <limits.h>
 
index 0836a4c96a0b486ef9e82f5a9d5eddcd27a23ae1..b379d8f8e720e2c691345f4a8a0f4d76e8e2706d 100644 (file)
@@ -18,6 +18,9 @@
 #include <netinet/in.h>
 #include <netdb.h>
 #include <string.h>
+#ifdef HAVE_LIBBSD
+#include <bsd/string.h>
+#endif
 
 #include "rt_names.h"
 #include "utils.h"
index 4d12fb5d19df29e3575a3594b28dbd5ed30a7749..c472fbd9a8790d1b779a6fa8d96995dfc8cd42d6 100644 (file)
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -19,6 +19,9 @@
 #include <sys/sysmacros.h>
 #include <netinet/in.h>
 #include <string.h>
+#ifdef HAVE_LIBBSD
+#include <bsd/string.h>
+#endif
 #include <errno.h>
 #include <netdb.h>
 #include <arpa/inet.h>
index 48b287f5ba3b267259f864d21033672e1287d968..550b2101a057907b163605a2218f056b5fd3d3f4 100644 (file)
@@ -20,6 +20,9 @@
 #include <netdb.h>
 #include <unistd.h>
 #include <string.h>
+#ifdef HAVE_LIBBSD
+#include <bsd/string.h>
+#endif
 #include <stdlib.h>
 #include <getopt.h>
 
index 2aeb56d9615f1e9ee4029aa5280c7170fe95e730..baacc80dd94b73b50540b70658c287ce58115bb2 100644 (file)
@@ -23,6 +23,9 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <string.h>
+#ifdef HAVE_LIBBSD
+#include <bsd/string.h>
+#endif
 #include <dlfcn.h>
 #include "utils.h"
 #include "tc_util.h"