From patchwork Wed Dec 17 16:07:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 422302 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2324E1400D2 for ; Thu, 18 Dec 2014 03:08:00 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=UxU/bcF8owH++9gaQsSz9uJF1y5Ze kcq9ZkJTiTWXOFLVVuMp73k4+rLE20ebsHeKFotBnUZe8wUXvmfxgRDxKEz0i6j5 VYmhNz5KYjQwwGc4nTaKSbrilar+K4FW7eQ3VN7ocKxHNa71y48+J8lRL1UvgTxh zf8DcqWFUdYRk4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=dWexugM3etLAr4C6NXRbVwNQyNc=; b=Coj qb0oDfKCgj69oUdwNkFiJVRixlEGLgZKZ8nLt33EVDA77loxBrvKtNSVJQ3pPoI2 mOT8jPSJ2CdA9pXYP9JqYQj5zoVl4WpMp8m0vVFq7K+usBVIp+Bxfma2k8Q2rlit L5rSU5Q8uzBVH9bNqLS17ru5jWv3PUxeWWlg8Aw0= Received: (qmail 12283 invoked by alias); 17 Dec 2014 16:07:53 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 12273 invoked by uid 89); 17 Dec 2014 16:07:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Date: Wed, 17 Dec 2014 16:07:48 +0000 From: Joseph Myers To: Subject: Fix resolver inet_* namespace (bug 17722) Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Parts of the resolver brought in by pthreads (at least) use inet_* functions that aren't in the 1995/6 edition of POSIX that introduced pthreads (or in one case, use __inet_aton which is then defined in the same file as non-weak inet_addr). This patch fixes this by making the affected functions into weak alias for __inet_* and using those names in the problematic resolver code. Tested for x86_64 (testsuite, and that disassembly of installed shared libraries is unchanged by the patch). 2014-12-17 Joseph Myers [BZ #17722] * inet/inet_mkadr.c (inet_makeaddr): Rename to __inet_makeaddr and define as weak alias of __inet_makeaddr. * resolv/inet_addr.c (inet_addr): Rename to __inet_addr and define as weak alias of __inet_addr. * resolv/inet_pton.c (inet_pton): Rename to __inet_pton and define as weak alias of __inet_pton. Use libc_hidden_weak. * include/arpa/inet.h (__inet_pton): Declare. Use libc_hidden_proto. (inet_makeaddr): Don't use libc_hidden_proto. (__inet_makeaddr): Declare. Use libc_hidden_proto. * resolv/res_init.c (__res_vinit): Use __inet_pton instead of inet_pton. Use __inet_makeaddr instead of inet_makeaddr. * conform/Makefile (test-xfail-POSIX/pthread.h/linknamespace): Remove variable. (test-xfail-POSIX/sched.h/linknamespace): Likewise. (test-xfail-POSIX/time.h/linknamespace): Likewise. diff --git a/conform/Makefile b/conform/Makefile index 45a17fb..5e6ac09 100644 --- a/conform/Makefile +++ b/conform/Makefile @@ -371,11 +371,8 @@ test-xfail-POSIX/aio.h/linknamespace = yes test-xfail-POSIX/fnmatch.h/linknamespace = yes test-xfail-POSIX/glob.h/linknamespace = yes test-xfail-POSIX/mqueue.h/linknamespace = yes -test-xfail-POSIX/pthread.h/linknamespace = yes test-xfail-POSIX/regex.h/linknamespace = yes -test-xfail-POSIX/sched.h/linknamespace = yes test-xfail-POSIX/semaphore.h/linknamespace = yes -test-xfail-POSIX/time.h/linknamespace = yes test-xfail-POSIX/unistd.h/linknamespace = yes test-xfail-POSIX/wordexp.h/linknamespace = yes test-xfail-UNIX98/ctype.h/linknamespace = yes diff --git a/include/arpa/inet.h b/include/arpa/inet.h index 63ece70..c3f28f2 100644 --- a/include/arpa/inet.h +++ b/include/arpa/inet.h @@ -7,6 +7,9 @@ libc_hidden_proto (__inet_aton) libc_hidden_proto (inet_aton) libc_hidden_proto (inet_ntop) libc_hidden_proto (inet_pton) -libc_hidden_proto (inet_makeaddr) +extern __typeof (inet_pton) __inet_pton; +libc_hidden_proto (__inet_pton) +extern __typeof (inet_makeaddr) __inet_makeaddr; +libc_hidden_proto (__inet_makeaddr) libc_hidden_proto (inet_netof) #endif diff --git a/inet/inet_mkadr.c b/inet/inet_mkadr.c index d8d92da..580a9cd 100644 --- a/inet/inet_mkadr.c +++ b/inet/inet_mkadr.c @@ -40,7 +40,7 @@ static char sccsid[] = "@(#)inet_makeaddr.c 8.1 (Berkeley) 6/4/93"; * building addresses stored in the ifnet structure. */ struct in_addr -inet_makeaddr(net, host) +__inet_makeaddr(net, host) in_addr_t net, host; { struct in_addr in; @@ -56,4 +56,5 @@ inet_makeaddr(net, host) in.s_addr = htonl(in.s_addr); return in; } -libc_hidden_def (inet_makeaddr) +libc_hidden_def (__inet_makeaddr) +weak_alias (__inet_makeaddr, inet_makeaddr) diff --git a/resolv/inet_addr.c b/resolv/inet_addr.c index 144b87a..ee42093 100644 --- a/resolv/inet_addr.c +++ b/resolv/inet_addr.c @@ -90,13 +90,14 @@ static const char rcsid[] = "$BINDId: inet_addr.c,v 8.11 1999/10/13 16:39:25 vix * The value returned is in network order. */ in_addr_t -inet_addr(const char *cp) { +__inet_addr(const char *cp) { struct in_addr val; if (__inet_aton(cp, &val)) return (val.s_addr); return (INADDR_NONE); } +weak_alias (__inet_addr, inet_addr) /* * Check whether "cp" is a valid ascii representation diff --git a/resolv/inet_pton.c b/resolv/inet_pton.c index c507013..3d88195 100644 --- a/resolv/inet_pton.c +++ b/resolv/inet_pton.c @@ -49,7 +49,7 @@ static int inet_pton6 (const char *src, u_char *dst) internal_function; * Paul Vixie, 1996. */ int -inet_pton(af, src, dst) +__inet_pton(af, src, dst) int af; const char *src; void *dst; @@ -65,7 +65,9 @@ inet_pton(af, src, dst) } /* NOTREACHED */ } -libc_hidden_def (inet_pton) +libc_hidden_def (__inet_pton) +weak_alias (__inet_pton, inet_pton) +libc_hidden_weak (inet_pton) /* int * inet_pton4(src, dst) diff --git a/resolv/res_init.c b/resolv/res_init.c index 6eddcdd..d492a08 100644 --- a/resolv/res_init.c +++ b/resolv/res_init.c @@ -324,7 +324,7 @@ __res_vinit(res_state statp, int preinit) { if ((el = strchr(cp, SCOPE_DELIMITER)) != NULL) *el = '\0'; if ((*cp != '\0') && - (inet_pton(AF_INET6, cp, &a6) > 0)) { + (__inet_pton(AF_INET6, cp, &a6) > 0)) { struct sockaddr_in6 *sa6; sa6 = malloc(sizeof(*sa6)); @@ -428,7 +428,7 @@ __res_vinit(res_state statp, int preinit) { (void) fclose(fp); } if (__builtin_expect(statp->nscount == 0, 0)) { - statp->nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1); + statp->nsaddr.sin_addr = __inet_makeaddr(IN_LOOPBACKNET, 1); statp->nsaddr.sin_family = AF_INET; statp->nsaddr.sin_port = htons(NAMESERVER_PORT); statp->nscount = 1;