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.
This commit is contained in:
parent
01cad84e19
commit
c4eae75271
16
ChangeLog
16
ChangeLog
@ -1,5 +1,21 @@
|
|||||||
2014-11-12 Joseph Myers <joseph@codesourcery.com>
|
2014-11-12 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
|
[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.
|
||||||
|
|
||||||
[BZ #17574]
|
[BZ #17574]
|
||||||
* wcsmbs/wmemset.c (wmemset): Rename to __wmemset and define as
|
* wcsmbs/wmemset.c (wmemset): Rename to __wmemset and define as
|
||||||
weak alias of __wmemset. Use libc_hidden_weak.
|
weak alias of __wmemset. Use libc_hidden_weak.
|
||||||
|
2
NEWS
2
NEWS
@ -11,7 +11,7 @@ Version 2.21
|
|||||||
|
|
||||||
6652, 12926, 14132, 14138, 14171, 15215, 15884, 17266, 17344, 17363,
|
6652, 12926, 14132, 14138, 14171, 15215, 15884, 17266, 17344, 17363,
|
||||||
17370, 17371, 17411, 17460, 17475, 17485, 17501, 17506, 17508, 17522,
|
17370, 17371, 17411, 17460, 17475, 17485, 17501, 17506, 17508, 17522,
|
||||||
17555, 17570, 17571, 17572, 17573, 17574, 17583, 17584.
|
17555, 17570, 17571, 17572, 17573, 17574, 17582, 17583, 17584.
|
||||||
|
|
||||||
* New locales: tu_IN, bh_IN.
|
* New locales: tu_IN, bh_IN.
|
||||||
|
|
||||||
|
@ -155,6 +155,8 @@ extern __typeof (fread_unlocked) __fread_unlocked;
|
|||||||
libc_hidden_proto (__fread_unlocked)
|
libc_hidden_proto (__fread_unlocked)
|
||||||
libc_hidden_proto (fwrite_unlocked)
|
libc_hidden_proto (fwrite_unlocked)
|
||||||
libc_hidden_proto (fgets_unlocked)
|
libc_hidden_proto (fgets_unlocked)
|
||||||
|
extern __typeof (fgets_unlocked) __fgets_unlocked;
|
||||||
|
libc_hidden_proto (__fgets_unlocked)
|
||||||
libc_hidden_proto (fputs_unlocked)
|
libc_hidden_proto (fputs_unlocked)
|
||||||
libc_hidden_proto (fmemopen)
|
libc_hidden_proto (fmemopen)
|
||||||
libc_hidden_proto (open_memstream)
|
libc_hidden_proto (open_memstream)
|
||||||
|
@ -73,6 +73,8 @@ _IO_fgets (buf, n, fp)
|
|||||||
weak_alias (_IO_fgets, fgets)
|
weak_alias (_IO_fgets, fgets)
|
||||||
|
|
||||||
# ifndef _IO_MTSAFE_IO
|
# ifndef _IO_MTSAFE_IO
|
||||||
|
strong_alias (_IO_fgets, __fgets_unlocked)
|
||||||
|
libc_hidden_def (__fgets_unlocked)
|
||||||
weak_alias (_IO_fgets, fgets_unlocked)
|
weak_alias (_IO_fgets, fgets_unlocked)
|
||||||
libc_hidden_weak (fgets_unlocked)
|
libc_hidden_weak (fgets_unlocked)
|
||||||
# endif
|
# endif
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
char *
|
char *
|
||||||
fgets_unlocked (buf, n, fp)
|
__fgets_unlocked (buf, n, fp)
|
||||||
char *buf;
|
char *buf;
|
||||||
int n;
|
int n;
|
||||||
_IO_FILE *fp;
|
_IO_FILE *fp;
|
||||||
@ -66,4 +66,6 @@ fgets_unlocked (buf, n, fp)
|
|||||||
fp->_IO_file_flags |= old_error;
|
fp->_IO_file_flags |= old_error;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
libc_hidden_def (fgets_unlocked)
|
libc_hidden_def (__fgets_unlocked)
|
||||||
|
weak_alias (__fgets_unlocked, fgets_unlocked)
|
||||||
|
libc_hidden_weak (fgets_unlocked)
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
the kernel will not generate them. 8192 bytes are really enough. \
|
the kernel will not generate them. 8192 bytes are really enough. \
|
||||||
If there is no "CPUs ..." line then we are on a UP system. */ \
|
If there is no "CPUs ..." line then we are on a UP system. */ \
|
||||||
(RESULT) = 1; \
|
(RESULT) = 1; \
|
||||||
while (fgets_unlocked ((BUFFER), sizeof (BUFFER), (FP)) != NULL) \
|
while (__fgets_unlocked ((BUFFER), sizeof (BUFFER), (FP)) != NULL) \
|
||||||
if ((sscanf (buffer, "cpus detected : %d", &(RESULT)) == 1) \
|
if ((sscanf (buffer, "cpus detected : %d", &(RESULT)) == 1) \
|
||||||
|| (sscanf (buffer, "CPUs probed %d", &(RESULT)) == 1)) \
|
|| (sscanf (buffer, "CPUs probed %d", &(RESULT)) == 1)) \
|
||||||
break; \
|
break; \
|
||||||
|
@ -299,7 +299,7 @@ phys_pages_info (const char *format)
|
|||||||
string "processor". We don't have to fear extremely long
|
string "processor". We don't have to fear extremely long
|
||||||
lines since the kernel will not generate them. 8192
|
lines since the kernel will not generate them. 8192
|
||||||
bytes are really enough. */
|
bytes are really enough. */
|
||||||
while (fgets_unlocked (buffer, sizeof buffer, fp) != NULL)
|
while (__fgets_unlocked (buffer, sizeof buffer, fp) != NULL)
|
||||||
if (sscanf (buffer, format, &result) == 1)
|
if (sscanf (buffer, format, &result) == 1)
|
||||||
{
|
{
|
||||||
result /= (__getpagesize () / 1024);
|
result /= (__getpagesize () / 1024);
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
probed cpus. We don't have to fear extremely long lines since \
|
probed cpus. We don't have to fear extremely long lines since \
|
||||||
the kernel will not generate them. 8192 bytes are really \
|
the kernel will not generate them. 8192 bytes are really \
|
||||||
enough. */ \
|
enough. */ \
|
||||||
while (fgets_unlocked ((BUFFER), sizeof (BUFFER), (FP)) != NULL) \
|
while (__fgets_unlocked ((BUFFER), sizeof (BUFFER), (FP)) != NULL) \
|
||||||
if (sscanf (buffer, "ncpus probed : %d", &(RESULT)) == 1) \
|
if (sscanf (buffer, "ncpus probed : %d", &(RESULT)) == 1) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user