]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix qsort_r namespace (bug 17571).
authorJoseph Myers <joseph@codesourcery.com>
Wed, 12 Nov 2014 22:33:41 +0000 (22:33 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Wed, 12 Nov 2014 22:33:41 +0000 (22:33 +0000)
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.

ChangeLog
NEWS
include/stdlib.h
nscd/gai.c
posix/tst-rfc3484-2.c
posix/tst-rfc3484-3.c
posix/tst-rfc3484.c
stdlib/msort.c
sysdeps/posix/getaddrinfo.c

index b7ec0f1eb5fe289e153f4228284cca219d1b68b0..236779e0893e4271e82dcad76476d00b22f48a9f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2014-11-12  Joseph Myers  <joseph@codesourcery.com>
 
+       [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.
+
        [BZ #17570]
        * malloc/malloc.c (malloc_info): Rename to __malloc_info and
        define as weak alias of __malloc_info.
diff --git a/NEWS b/NEWS
index 5017517fe89822e6c39664add363ad9a9c46b6b9..5f3d4b47f27fe0fef36cdaf3ca12fe54a11f4fb0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,7 +11,7 @@ Version 2.21
 
   6652, 12926, 14132, 14138, 14171, 15215, 15884, 17266, 17344, 17363,
   17370, 17371, 17411, 17460, 17475, 17485, 17501, 17506, 17508, 17522,
-  17555, 17570, 17583, 17584.
+  17555, 17570, 17571, 17583, 17584.
 
 * New locales: tu_IN, bh_IN.
 \f
index 8d8c75368f314266ad11ebc44155a5130b45028f..b8efbd7b3a5630d0c27a9c287f6d1daea3434b36 100644 (file)
@@ -37,7 +37,8 @@ extern __typeof (secure_getenv) __libc_secure_getenv;
 libc_hidden_proto (__libc_secure_getenv)
 libc_hidden_proto (bsearch)
 libc_hidden_proto (qsort)
-libc_hidden_proto (qsort_r)
+extern __typeof (qsort_r) __qsort_r;
+libc_hidden_proto (__qsort_r)
 libc_hidden_proto (lrand48_r)
 libc_hidden_proto (wctomb)
 
index 95373e4ecbf1507dadcc1cfbf73770b357704bd7..c159c0bee2d77f5b7e5a80cc3c958cfce8065814 100644 (file)
@@ -28,6 +28,7 @@
 #define __sendto sendto
 #define __strchrnul strchrnul
 #define __getline getline
+#define __qsort_r qsort_r
 /* nscd uses 1MB or 2MB thread stacks.  */
 #define __libc_use_alloca(size) (size <= __MAX_ALLOCA_CUTOFF)
 
index fcf8a8cd60236fe3c2c7fa85248154121bcb15d4..ee9281394b24810b59f52226f8314dd447e8336d 100644 (file)
@@ -10,6 +10,7 @@
 #define __inet_aton inet_aton
 #define __gethostbyaddr_r gethostbyaddr_r
 #define __gethostbyname2_r gethostbyname2_r
+#define __qsort_r qsort_r
 
 void
 attribute_hidden
index 86d59be1abb08ad1fad951a088dc3f47864524b3..c987366e4e45aa37d35bd4b780a22559b23dc0b7 100644 (file)
@@ -10,6 +10,7 @@
 #define __inet_aton inet_aton
 #define __gethostbyaddr_r gethostbyaddr_r
 #define __gethostbyname2_r gethostbyname2_r
+#define __qsort_r qsort_r
 
 void
 attribute_hidden
index 2726fa0ad9e6d6052e813f3d4856d2365a097cd3..73c4dffcf50a84feb2986f3565cc3638417e13e0 100644 (file)
@@ -10,6 +10,7 @@
 #define __inet_aton inet_aton
 #define __gethostbyaddr_r gethostbyaddr_r
 #define __gethostbyname2_r gethostbyname2_r
+#define __qsort_r qsort_r
 
 void
 attribute_hidden
index 02ef28b89d9e1be5caa1b605b61d25bbfdfd9a3c..5ac5df710d803559c40a2b6814f88abd9b36ed5a 100644 (file)
@@ -162,7 +162,7 @@ msort_with_tmp (const struct msort_param *p, void *b, size_t n)
 
 
 void
-qsort_r (void *b, size_t n, size_t s, __compar_d_fn_t cmp, void *arg)
+__qsort_r (void *b, size_t n, size_t s, __compar_d_fn_t cmp, void *arg)
 {
   size_t size = n * s;
   char *tmp = NULL;
@@ -298,12 +298,13 @@ qsort_r (void *b, size_t n, size_t s, __compar_d_fn_t cmp, void *arg)
     }
   free (tmp);
 }
-libc_hidden_def (qsort_r)
+libc_hidden_def (__qsort_r)
+weak_alias (__qsort_r, qsort_r)
 
 
 void
 qsort (void *b, size_t n, size_t s, __compar_fn_t cmp)
 {
-  return qsort_r (b, n, s, (__compar_d_fn_t) cmp, NULL);
+  return __qsort_r (b, n, s, (__compar_d_fn_t) cmp, NULL);
 }
 libc_hidden_def (qsort)
index 8f392b9678c1da2947196af2bd21964c6b4fdafe..31bb7e66dcbe1868b8e5e34185e048fe5bde15ab 100644 (file)
@@ -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;