Fix getifaddrs, freeifaddrs namespace on non-Linux
Commit Message
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(-)
Comments
Aurelien Jarno <aurelien@aurel32.net> writes:
> 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)
You need the hidden_proto on the __ names.
Andreas.
On 2015-12-14 09:58, Andreas Schwab wrote:
> Aurelien Jarno <aurelien@aurel32.net> writes:
>
> > 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)
>
> You need the hidden_proto on the __ names.
If I understand correctly doing so also means adding a hidden_def on
the __ names in ifaddrs.c. Is it correct?
On 19 Dec 2015 00:29, Aurelien Jarno wrote:
> On 2015-12-14 09:58, Andreas Schwab wrote:
> > Aurelien Jarno <aurelien@aurel32.net> writes:
> > > --- 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)
> >
> > You need the hidden_proto on the __ names.
>
> If I understand correctly doing so also means adding a hidden_def on
> the __ names in ifaddrs.c. Is it correct?
yep
-mike
@@ -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
@@ -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
@@ -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);
}
@@ -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)