From bef8fd6013f7d398661077340753c745a8939279 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Wed, 12 Nov 2014 22:33:41 +0000 Subject: Fix qsort_r namespace (bug 17571). qsort_r is defined in the same file as qsort, but is not an ISO C function, so should be a weak alias for __qsort_r. The uses in getaddrinfo should also call __qsort_r, since getaddrinfo is a POSIX function and qsort_r isn't. This patch implements this. Because nscd uses the getaddrinfo sources outside libc, as do the tst-rfc3484 tests, a #define of __qsort_r to qsort_r is added there alongside the similar defines for other libc-internal symbols used in getaddrinfo. Tested for x86_64 (testsuite, and that disassembly of installed shared libraries is unchanged by the patch). [BZ #17571] * stdlib/msort.c (qsort_r): Rename to __qsort_r and define as weak alias of __qsort_r. (qsort): Call __qsort_r instead of qsort_r. * include/stdlib.h (qsort_r): Do not call libc_hidden_proto. (__qsort_r): Declare. Call libc_hidden_proto. * sysdeps/posix/getaddrinfo.c (getaddrinfo): Call __qsort_r instead of qsort_r. * nscd/gai.c (__qsort_r): Define to qsort_r. * posix/tst-rfc3484.c (__qsort_r): Likewise. * posix/tst-rfc3484-2.c (__qsort_r): Likewise. * posix/tst-rfc3484-3.c (__qsort_r): Likewise. --- sysdeps/posix/getaddrinfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sysdeps/posix/getaddrinfo.c') diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index 8f392b9678..31bb7e66dc 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -2626,11 +2626,11 @@ getaddrinfo (const char *name, const char *service, __libc_lock_lock (lock); if (__libc_once_get (old_once) && gaiconf_reload_flag) gaiconf_reload (); - qsort_r (order, nresults, sizeof (order[0]), rfc3484_sort, &src); + __qsort_r (order, nresults, sizeof (order[0]), rfc3484_sort, &src); __libc_lock_unlock (lock); } else - qsort_r (order, nresults, sizeof (order[0]), rfc3484_sort, &src); + __qsort_r (order, nresults, sizeof (order[0]), rfc3484_sort, &src); /* Queue the results up as they come out of sorting. */ q = p = results[order[0]].dest_addr; -- cgit 1.4.1