From c4eae75271734f820a7477dbce33f8752af6f003 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Wed, 12 Nov 2014 22:39:36 +0000 Subject: Fix __get_nprocs fgets_unlocked namespace (bug 17582). __get_nprocs is called from malloc code, but calls fgets_unlocked, which is not an ISO C or POSIX function. This patch fixes it to call a new __fgets_unlocked name instead. Note: there are various other uses of fgets_unlocked in glibc's libraries, and I haven't yet investigated which others might also be problematic (called directly or indirectly from standard functions) and so need to change to use __fgets_unlocked. Tested for x86_64 (testsuite, and that disassembly of installed shared libraries is unchanged by the patch). [BZ #17582] * libio/iofgets.c [weak_alias && !_IO_MTSAFE_IO] (__fgets_unlocked): Add alias of _IO_fgets. Use libc_hidden_def. * libio/iofgets_u.c (fgets_unlocked): Rename to __fgets_unlocked and define as weak alias of __fgets_unlocked. Use libc_hidden_weak. (__fgets_unlocked): Use libc_hidden_def. * include/stdio.h (__fgets_unlocked): Declare. Use libc_hidden_proto. * sysdeps/unix/sysv/linux/getsysstats.c (phys_pages_info): Use __fgets_unlocked instead of fgets_unlocked. * sysdeps/unix/sysv/linux/alpha/getsysstats.c (GET_NPROCS_CONF_PARSER): Likewise. * sysdeps/unix/sysv/linux/sparc/getsysstats.c (GET_NPROCS_CONF_PARSER): Likewise. --- libio/iofgets_u.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libio/iofgets_u.c') diff --git a/libio/iofgets_u.c b/libio/iofgets_u.c index b2d4d8fe2b..d338ee0ad3 100644 --- a/libio/iofgets_u.c +++ b/libio/iofgets_u.c @@ -28,7 +28,7 @@ #include char * -fgets_unlocked (buf, n, fp) +__fgets_unlocked (buf, n, fp) char *buf; int n; _IO_FILE *fp; @@ -66,4 +66,6 @@ fgets_unlocked (buf, n, fp) fp->_IO_file_flags |= old_error; return result; } -libc_hidden_def (fgets_unlocked) +libc_hidden_def (__fgets_unlocked) +weak_alias (__fgets_unlocked, fgets_unlocked) +libc_hidden_weak (fgets_unlocked) -- cgit 1.4.1