]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix fgets_unlocked namespace issues (bug 17664).
authorJoseph Myers <joseph@codesourcery.com>
Tue, 2 Dec 2014 21:31:24 +0000 (21:31 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Tue, 2 Dec 2014 21:31:24 +0000 (21:31 +0000)
Various POSIX functions bring in res_init.o, res_hconf.o or
mntent_r.o, which use fgets_unlocked, which is not a POSIX function.
This patch arranges for them to use __fgets_unlocked instead.  (The
IS_IN (libc) conditional in rec_hconf.c is needed because that file is
also used in nscd.)

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by the patch except for an assertion line
number).  Note that most of the linknamespace tests that failed
because of fgets_unlocked from the resolver also fail because of other
symbols brought in by the resolver, so the number of XFAILs this
removes is limited.  Also note that fgets_unlocked failures for
unistd.h for XPG3/XPG4 showed up that actually unistd.h is declaring
too much for XPG3/XPG4 (bug 17665) - there is no actual need to make
getusershell.c use __fgets_unlocked (at least as regards formal
standards are concerned; maybe it should still change for
namespace-cleanness of _DEFAULT_SOURCE) because the functions there
aren't actually in any of the supported standards; the correct fix for
those failures will be to stop the *usershell* functions appearing in
unistd.h for XPG3/XPG4.

[BZ #17664]
* misc/mntent_r.c (__getmntent_r): Use __fgets_unlocked instead of
fgets_unlocked.
* resolv/res_hconf.c [IS_IN (libc)] (fgets_unlocked): Define to
__fgets_unlocked.
* resolv/res_init.c (__res_vinit): Use __fgets_unlocked instead of
fgets_unlocked.
* conform/Makefile (test-xfail-XPG4/sys/statvfs.h/linknamespace):
Remove variable.
(test-xfail-POSIX/sys/mman.h/linknamespace): Likewise.
(test-xfail-UNIX98/sys/mman.h/linknamespace): Likewise.
(test-xfail-UNIX98/sys/statvfs.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/sys/mman.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/sys/statvfs.h/linknamespace): Likewise.
(test-xfail-POSIX2008/sys/mman.h/linknamespace): Likewise.
(test-xfail-POSIX2008/sys/statvfs.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/sys/mman.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/sys/statvfs.h/linknamespace): Likewise.

ChangeLog
NEWS
conform/Makefile
misc/mntent_r.c
resolv/res_hconf.c
resolv/res_init.c

index 8e61f353baa59601109f9c19495ef022e6780d9f..f532ed6b1a40fdf3cc10c58a44e971b8571e2723 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
 2014-12-02  Joseph Myers  <joseph@codesourcery.com>
 
+       [BZ #17664]
+       * misc/mntent_r.c (__getmntent_r): Use __fgets_unlocked instead of
+       fgets_unlocked.
+       * resolv/res_hconf.c [IS_IN (libc)] (fgets_unlocked): Define to
+       __fgets_unlocked.
+       * resolv/res_init.c (__res_vinit): Use __fgets_unlocked instead of
+       fgets_unlocked.
+       * conform/Makefile (test-xfail-XPG4/sys/statvfs.h/linknamespace):
+       Remove variable.
+       (test-xfail-POSIX/sys/mman.h/linknamespace): Likewise.
+       (test-xfail-UNIX98/sys/mman.h/linknamespace): Likewise.
+       (test-xfail-UNIX98/sys/statvfs.h/linknamespace): Likewise.
+       (test-xfail-XOPEN2K/sys/mman.h/linknamespace): Likewise.
+       (test-xfail-XOPEN2K/sys/statvfs.h/linknamespace): Likewise.
+       (test-xfail-POSIX2008/sys/mman.h/linknamespace): Likewise.
+       (test-xfail-POSIX2008/sys/statvfs.h/linknamespace): Likewise.
+       (test-xfail-XOPEN2K8/sys/mman.h/linknamespace): Likewise.
+       (test-xfail-XOPEN2K8/sys/statvfs.h/linknamespace): Likewise.
+
        * elf/tst-unique4lib.cc (b): Mark with __attribute__ ((used)).
 
 2014-12-02  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
diff --git a/NEWS b/NEWS
index 5450e8e0d1103ac7ecdaaa6b414593baf17528f6..fe5453cba223aa9d375ba2676e4b56f6c3a84f64 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,7 +13,7 @@ Version 2.21
   16619, 16740, 16857, 17192, 17266, 17344, 17363, 17370, 17371, 17411,
   17460, 17475, 17485, 17501, 17506, 17508, 17522, 17555, 17570, 17571,
   17572, 17573, 17574, 17581, 17582, 17583, 17584, 17585, 17589, 17594,
-  17608, 17616, 17625, 17633.
+  17608, 17616, 17625, 17633, 17664.
 
 * CVE-2104-7817 The wordexp function could ignore the WRDE_NOCMD flag
   under certain input conditions resulting in the execution of a shell for
index 641f5465deb6437d7672da643d9f01a2a8bb9691..eed28430437a41cbcc11e3606143013e57e3a25d 100644 (file)
@@ -369,7 +369,6 @@ test-xfail-XPG4/regex.h/linknamespace = yes
 test-xfail-XPG4/search.h/linknamespace = yes
 test-xfail-XPG4/stdio.h/linknamespace = yes
 test-xfail-XPG4/stdlib.h/linknamespace = yes
-test-xfail-XPG4/sys/statvfs.h/linknamespace = yes
 test-xfail-XPG4/syslog.h/linknamespace = yes
 test-xfail-XPG4/time.h/linknamespace = yes
 test-xfail-XPG4/unistd.h/linknamespace = yes
@@ -382,7 +381,6 @@ 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/sys/mman.h/linknamespace = yes
 test-xfail-POSIX/time.h/linknamespace = yes
 test-xfail-POSIX/unistd.h/linknamespace = yes
 test-xfail-POSIX/wordexp.h/linknamespace = yes
@@ -403,8 +401,6 @@ test-xfail-UNIX98/search.h/linknamespace = yes
 test-xfail-UNIX98/semaphore.h/linknamespace = yes
 test-xfail-UNIX98/stdio.h/linknamespace = yes
 test-xfail-UNIX98/stdlib.h/linknamespace = yes
-test-xfail-UNIX98/sys/mman.h/linknamespace = yes
-test-xfail-UNIX98/sys/statvfs.h/linknamespace = yes
 test-xfail-UNIX98/syslog.h/linknamespace = yes
 test-xfail-UNIX98/time.h/linknamespace = yes
 test-xfail-UNIX98/unistd.h/linknamespace = yes
@@ -428,8 +424,6 @@ test-xfail-XOPEN2K/semaphore.h/linknamespace = yes
 test-xfail-XOPEN2K/signal.h/linknamespace = yes
 test-xfail-XOPEN2K/spawn.h/linknamespace = yes
 test-xfail-XOPEN2K/stdlib.h/linknamespace = yes
-test-xfail-XOPEN2K/sys/mman.h/linknamespace = yes
-test-xfail-XOPEN2K/sys/statvfs.h/linknamespace = yes
 test-xfail-XOPEN2K/sys/wait.h/linknamespace = yes
 test-xfail-XOPEN2K/syslog.h/linknamespace = yes
 test-xfail-XOPEN2K/time.h/linknamespace = yes
@@ -448,8 +442,6 @@ test-xfail-POSIX2008/pthread.h/linknamespace = yes
 test-xfail-POSIX2008/regex.h/linknamespace = yes
 test-xfail-POSIX2008/semaphore.h/linknamespace = yes
 test-xfail-POSIX2008/spawn.h/linknamespace = yes
-test-xfail-POSIX2008/sys/mman.h/linknamespace = yes
-test-xfail-POSIX2008/sys/statvfs.h/linknamespace = yes
 test-xfail-POSIX2008/time.h/linknamespace = yes
 test-xfail-POSIX2008/unistd.h/linknamespace = yes
 test-xfail-XOPEN2K8/aio.h/linknamespace = yes
@@ -467,8 +459,6 @@ test-xfail-XOPEN2K8/regex.h/linknamespace = yes
 test-xfail-XOPEN2K8/search.h/linknamespace = yes
 test-xfail-XOPEN2K8/semaphore.h/linknamespace = yes
 test-xfail-XOPEN2K8/spawn.h/linknamespace = yes
-test-xfail-XOPEN2K8/sys/mman.h/linknamespace = yes
-test-xfail-XOPEN2K8/sys/statvfs.h/linknamespace = yes
 test-xfail-XOPEN2K8/syslog.h/linknamespace = yes
 test-xfail-XOPEN2K8/time.h/linknamespace = yes
 test-xfail-XOPEN2K8/unistd.h/linknamespace = yes
index e68ec8e845a1de3a4fbb45fb4923c174ecc373ea..0d5c2e3534cc4dc4af1b830753106d3c47bc812c 100644 (file)
@@ -127,7 +127,7 @@ __getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz)
     {
       char *end_ptr;
 
-      if (fgets_unlocked (buffer, bufsiz, stream) == NULL)
+      if (__fgets_unlocked (buffer, bufsiz, stream) == NULL)
        {
          funlockfile (stream);
          return NULL;
@@ -140,7 +140,7 @@ __getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz)
        {
          /* Not the whole line was read.  Do it now but forget it.  */
          char tmp[1024];
-         while (fgets_unlocked (tmp, sizeof tmp, stream) != NULL)
+         while (__fgets_unlocked (tmp, sizeof tmp, stream) != NULL)
            if (strchr (tmp, '\n') != NULL)
              break;
        }
index cde02293307435358cb76069f683e38ff8a0a8d7..6693b1216ea10ff15113775ce6a220ef24d95f54 100644 (file)
 #include "res_hconf.h"
 #include <wchar.h>
 
+#if IS_IN (libc)
+# define fgets_unlocked __fgets_unlocked
+#endif
+
 #define _PATH_HOSTCONF "/etc/host.conf"
 
 /* Environment vars that all user to override default behavior:  */
index ea133f8d8212c76eaee9c12ef4bd980c1fff6549..90760ec8e65d73894edfc7ed7bf3ba2cb9ebc9bf 100644 (file)
@@ -238,7 +238,7 @@ __res_vinit(res_state statp, int preinit) {
            /* No threads use this stream.  */
            __fsetlocking (fp, FSETLOCKING_BYCALLER);
            /* read the config file */
-           while (fgets_unlocked(buf, sizeof(buf), fp) != NULL) {
+           while (__fgets_unlocked(buf, sizeof(buf), fp) != NULL) {
                /* skip comments */
                if (*buf == ';' || *buf == '#')
                        continue;