This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix getifaddrs, freeifaddrs namespace on non-Linux


Commit 7f994279 addressed the getifaddrs, freeifaddrs namespace issue on
Linux, but this issue is also present on non-Linux via check_pf:

  freeaddrinfo -> [libc.a(getaddrinfo.o)] __check_pf -> libc.a(check_pf.o)] freeifaddrs

This patch fixes this issue by fixing the generic check_pf version to
call __getifaddrs and __freeifaddrs instead of getifaddrs and
freeifaddrs. As check_pf.c is also included directly from nscd/gai.c,
we need to use defines to revert this change there.
---
 ChangeLog         | 9 +++++++++
 include/ifaddrs.h | 2 ++
 inet/check_pf.c   | 4 ++--
 nscd/gai.c        | 2 ++
 4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 13be8a8..3fb0b90 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2015-12-12  Aurelien Jarno  <aurelien@aurel32.net>
+
+	* include/ifaddrs.h (__getifaddrs): Declare.
+	(__freeifaddrs): Declare.
+	* inet/check_pf.c (__check_pf): Call __getifaddrs instead of
+	getifaddrs.  Call __freeifaddrs instead of freeifaddrs.
+	* nscd/gai.c (__getifaddrs): Define to getifaddrs.
+	(__freeifaddrs): define to freeifaddrs.
+
 2015-12-11  Aurelien Jarno  <aurelien@aurel32.net>
 
 	* sysdeps/unix/sysv/linux/arm/ioperm.c: Do not include
diff --git a/include/ifaddrs.h b/include/ifaddrs.h
index 2787f21..7c52ccf 100644
--- a/include/ifaddrs.h
+++ b/include/ifaddrs.h
@@ -3,7 +3,9 @@
 #include <stdbool.h>
 #include <stdint.h>
 
+extern __typeof(getifaddrs) __getifaddrs;
 libc_hidden_proto (getifaddrs)
+extern __typeof(freeifaddrs) __freeifaddrs;
 libc_hidden_proto (freeifaddrs)
 
 struct in6addrinfo
diff --git a/inet/check_pf.c b/inet/check_pf.c
index 3739a95..c49d6b5 100644
--- a/inet/check_pf.c
+++ b/inet/check_pf.c
@@ -32,7 +32,7 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6,
 
   /* Get the interface list via getifaddrs.  */
   struct ifaddrs *ifa = NULL;
-  if (getifaddrs (&ifa) != 0)
+  if (__getifaddrs (&ifa) != 0)
     {
       /* We cannot determine what interfaces are available.  Be
 	 pessimistic.  */
@@ -51,7 +51,7 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6,
     else if (runp->ifa_addr->sa_family == PF_INET6)
       *seen_ipv6 = true;
 
-  (void) freeifaddrs (ifa);
+  (void) __freeifaddrs (ifa);
 }
 
 
diff --git a/nscd/gai.c b/nscd/gai.c
index 9a52a97..dc289d6 100644
--- a/nscd/gai.c
+++ b/nscd/gai.c
@@ -29,6 +29,8 @@
 #define __strchrnul strchrnul
 #define __getline getline
 #define __qsort_r qsort_r
+#define __getifaddrs getifaddrs
+#define __freeifaddrs freeifaddrs
 /* nscd uses 1MB or 2MB thread stacks.  */
 #define __libc_use_alloca(size) (size <= __MAX_ALLOCA_CUTOFF)
 
-- 
2.6.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]