From 4775578486c8ee2aa09b402eb272eb932e7e0691 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Tue, 23 Aug 2016 21:19:17 -0400 Subject: Installed header hygiene (BZ#20366): Test of installed headers. This adds a test to ensure that the problems fixed in the last several patches do not recur. Each directory checks the headers that it installs for two properties: first, each header must be compilable in isolation, as both C and C++, under a representative combination of language and library conformance levels; second, there is a blacklist of identifiers that may not appear in any installed header, currently consisting of the legacy BSD typedefs. (There is an exemption for the headers that define those typedefs, and for the RPC headers. It may be necessary to make this more sophisticated if we add more stuff to the blacklist in the future.) In order for this test to work correctly, every wrapper header that actually defines something must guard those definitions with #ifndef _ISOMAC. This is the existing mechanism used by the conform/ tests to tell wrapper headers not to define anything that the public header wouldn't, and not to use anything from libc-symbols.h. conform/ only cares for headers that we need to check for standards conformance, whereas this test applies to *every* header. (Headers in include/ that are either installed directly, or are internal-use-only and do *not* correspond to any installed header, are not affected.) * scripts/check-installed-headers.sh: New script. * Rules: In each directory that defines header files to be installed, run check-installed-headers.sh on them as a special test. * Makefile: Likewise for the headers installed at top level. * include/aliases.h, include/alloca.h, include/argz.h * include/arpa/nameser.h, include/arpa/nameser_compat.h * include/elf.h, include/envz.h, include/err.h * include/execinfo.h, include/fpu_control.h, include/getopt.h * include/gshadow.h, include/ifaddrs.h, include/libintl.h * include/link.h, include/malloc.h, include/mcheck.h * include/mntent.h, include/netinet/ether.h * include/nss.h, include/obstack.h, include/printf.h * include/pty.h, include/resolv.h, include/rpc/auth.h * include/rpc/auth_des.h, include/rpc/auth_unix.h * include/rpc/clnt.h, include/rpc/des_crypt.h * include/rpc/key_prot.h, include/rpc/netdb.h * include/rpc/pmap_clnt.h, include/rpc/pmap_prot.h * include/rpc/pmap_rmt.h, include/rpc/rpc.h * include/rpc/rpc_msg.h, include/rpc/svc.h * include/rpc/svc_auth.h, include/rpc/xdr.h * include/rpcsvc/nis_callback.h, include/rpcsvc/nislib.h * include/rpcsvc/yp.h, include/rpcsvc/ypclnt.h * include/rpcsvc/ypupd.h, include/shadow.h * include/stdio_ext.h, include/sys/epoll.h * include/sys/file.h, include/sys/gmon.h, include/sys/ioctl.h * include/sys/prctl.h, include/sys/profil.h * include/sys/statfs.h, include/sys/sysctl.h * include/sys/sysinfo.h, include/ttyent.h, include/utmp.h * sysdeps/arm/nacl/include/bits/setjmp.h * sysdeps/mips/include/sys/asm.h * sysdeps/unix/sysv/linux/include/sys/sysinfo.h * sysdeps/unix/sysv/linux/include/sys/timex.h * sysdeps/x86/fpu/include/bits/fenv.h: Add #ifndef _ISOMAC guard around internal declarations. Add multiple-inclusion guard if not already present. --- include/ifaddrs.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/ifaddrs.h') diff --git a/include/ifaddrs.h b/include/ifaddrs.h index 2787f21115..54f4b7a3ce 100644 --- a/include/ifaddrs.h +++ b/include/ifaddrs.h @@ -1,5 +1,8 @@ #ifndef _IFADDRS_H #include + +# ifndef _ISOMAC + #include #include @@ -30,4 +33,5 @@ extern void __check_native (uint32_t a1_index, int *a1_native, extern uint32_t __bump_nl_timestamp (void) attribute_hidden; #endif +# endif /* !_ISOMAC */ #endif /* ifaddrs.h */ -- cgit v1.2.3 From 4009ddc69225d571772aaea597615a0c032e14ab Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 28 Sep 2017 00:19:18 +0200 Subject: hurd: Fix `getifaddrs' and `freeifaddrs' symbol exposition from `freeaddrinfo'. `getifaddrs' and `freeifaddrs' are not in POSIX, they should not be exposed along `freeaddrinfo' (through `__check_pf') which is POSIX. * include/ifaddrs.h (__getifaddrs, __freeifaddrs): New declarations, and use libc_hidden_def on them. * inet/ifaddrs.c (__getifaddrs, __freeifaddrs): Use libc_hidden_def on them. * sysdeps/gnu/ifaddrs.c (__getifaddrs, __freeifaddrs): Likewise. * inet/check_pf.c (__check_pf): Use __getifaddrs and __freeifaddrs instead of getifaddrs and freeifaddrs. --- ChangeLog | 7 +++++++ include/ifaddrs.h | 5 +++++ inet/check_pf.c | 4 ++-- inet/ifaddrs.c | 2 ++ sysdeps/gnu/ifaddrs.c | 2 ++ 5 files changed, 18 insertions(+), 2 deletions(-) (limited to 'include/ifaddrs.h') diff --git a/ChangeLog b/ChangeLog index 737dc8f808..8e26c003a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,13 @@ redefine as weak alias. * sysdeps/mach/hurd/rewinddir.c (__rewinddir): Use __seekdir instead of seekdir. + * include/ifaddrs.h (__getifaddrs, __freeifaddrs): New declarations, + and use libc_hidden_def on them. + * inet/ifaddrs.c (__getifaddrs, __freeifaddrs): Use libc_hidden_def on + them. + * sysdeps/gnu/ifaddrs.c (__getifaddrs, __freeifaddrs): Likewise. + * inet/check_pf.c (__check_pf): Use __getifaddrs and __freeifaddrs + instead of getifaddrs and freeifaddrs. 2017-09-26 H.J. Lu diff --git a/include/ifaddrs.h b/include/ifaddrs.h index 54f4b7a3ce..416118f1b3 100644 --- a/include/ifaddrs.h +++ b/include/ifaddrs.h @@ -9,6 +9,11 @@ libc_hidden_proto (getifaddrs) libc_hidden_proto (freeifaddrs) +extern int __getifaddrs (struct ifaddrs **__ifap); +libc_hidden_proto (__getifaddrs) +extern void __freeifaddrs (struct ifaddrs *__ifa); +libc_hidden_proto (__freeifaddrs) + struct in6addrinfo { enum { diff --git a/inet/check_pf.c b/inet/check_pf.c index a56723a7df..84dd1699d5 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/inet/ifaddrs.c b/inet/ifaddrs.c index 35cc277225..0a5c71c059 100644 --- a/inet/ifaddrs.c +++ b/inet/ifaddrs.c @@ -30,6 +30,7 @@ __getifaddrs (struct ifaddrs **ifap) return -1; } weak_alias (__getifaddrs, getifaddrs) +libc_hidden_def (__getifaddrs) libc_hidden_weak (getifaddrs) stub_warning (getifaddrs) @@ -43,5 +44,6 @@ __freeifaddrs (struct ifaddrs *ifa) abort (); } weak_alias (__freeifaddrs, freeifaddrs) +libc_hidden_def (__freeifaddrs) libc_hidden_weak (freeifaddrs) stub_warning (freeifaddrs) diff --git a/sysdeps/gnu/ifaddrs.c b/sysdeps/gnu/ifaddrs.c index 37b3248669..80702eb1d1 100644 --- a/sysdeps/gnu/ifaddrs.c +++ b/sysdeps/gnu/ifaddrs.c @@ -151,6 +151,7 @@ __getifaddrs (struct ifaddrs **ifap) return 0; } weak_alias (__getifaddrs, getifaddrs) +libc_hidden_def (__getifaddrs) #ifndef getifaddrs libc_hidden_weak (getifaddrs) #endif @@ -161,4 +162,5 @@ __freeifaddrs (struct ifaddrs *ifa) free (ifa); } weak_alias (__freeifaddrs, freeifaddrs) +libc_hidden_def (__freeifaddrs) libc_hidden_weak (freeifaddrs) -- cgit v1.2.3