mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Fix locale memmem namespace (bug 17585).
Locale code, brought in by ISO C functions, calls memmem, which is not an ISO C function. This isn't an ISO C conformance bug, because all mem* names are reserved, but glibc practice is not to rely on that reservation (thus, memmem is only declared in string.h if __USE_GNU even though ISO C would allow it to be declared unconditionally, for example). This patch changes that code to use __memmem. Note: there are uses of memmem elsewhere in glibc that I didn't change, although it may turn out some of those also need to use __memmem. Tested for x86_64 (testsuite, and that disassembly of installed shared libraries is unchanged by this patch). [BZ #17585] * string/memmem.c [!_LIBC] (__memmem): Define to memmem. (memmem): Rename to __memmem and define as weak alias of __memmem. Use libc_hidden_weak. (__memmem): Use libc_hidden_def. * include/string.h (__memmem): Declare. Use libc_hidden_proto. * locale/findlocale.c (valid_locale_name): Use __memmem instead of memmem.
This commit is contained in:
@ -1,5 +1,14 @@
|
|||||||
2014-11-12 Joseph Myers <joseph@codesourcery.com>
|
2014-11-12 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
|
[BZ #17585]
|
||||||
|
* string/memmem.c [!_LIBC] (__memmem): Define to memmem.
|
||||||
|
(memmem): Rename to __memmem and define as weak alias of
|
||||||
|
__memmem. Use libc_hidden_weak.
|
||||||
|
(__memmem): Use libc_hidden_def.
|
||||||
|
* include/string.h (__memmem): Declare. Use libc_hidden_proto.
|
||||||
|
* locale/findlocale.c (valid_locale_name): Use __memmem instead of
|
||||||
|
memmem.
|
||||||
|
|
||||||
[BZ #17582]
|
[BZ #17582]
|
||||||
* libio/iofgets.c [weak_alias && !_IO_MTSAFE_IO]
|
* libio/iofgets.c [weak_alias && !_IO_MTSAFE_IO]
|
||||||
(__fgets_unlocked): Add alias of _IO_fgets. Use libc_hidden_def.
|
(__fgets_unlocked): Add alias of _IO_fgets. Use libc_hidden_def.
|
||||||
|
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, 17582, 17583, 17584.
|
17555, 17570, 17571, 17572, 17573, 17574, 17582, 17583, 17584, 17585.
|
||||||
|
|
||||||
* New locales: tu_IN, bh_IN.
|
* New locales: tu_IN, bh_IN.
|
||||||
|
|
||||||
|
@ -90,6 +90,8 @@ extern char *__strsep_g (char **__stringp, const char *__delim);
|
|||||||
libc_hidden_proto (__strsep_g)
|
libc_hidden_proto (__strsep_g)
|
||||||
libc_hidden_proto (strnlen)
|
libc_hidden_proto (strnlen)
|
||||||
libc_hidden_proto (memmem)
|
libc_hidden_proto (memmem)
|
||||||
|
extern __typeof (memmem) __memmem;
|
||||||
|
libc_hidden_proto (__memmem)
|
||||||
libc_hidden_proto (__ffs)
|
libc_hidden_proto (__ffs)
|
||||||
|
|
||||||
libc_hidden_builtin_proto (memchr)
|
libc_hidden_builtin_proto (memchr)
|
||||||
|
@ -79,7 +79,7 @@ valid_locale_name (const char *name)
|
|||||||
return 0;
|
return 0;
|
||||||
/* Directory traversal attempt. */
|
/* Directory traversal attempt. */
|
||||||
static const char slashdot[4] = {'/', '.', '.', '/'};
|
static const char slashdot[4] = {'/', '.', '.', '/'};
|
||||||
if (__glibc_unlikely (memmem (name, namelen,
|
if (__glibc_unlikely (__memmem (name, namelen,
|
||||||
slashdot, sizeof (slashdot)) != NULL))
|
slashdot, sizeof (slashdot)) != NULL))
|
||||||
return 0;
|
return 0;
|
||||||
if (namelen == 2 && __glibc_unlikely (name[0] == '.' && name [1] == '.'))
|
if (namelen == 2 && __glibc_unlikely (name[0] == '.' && name [1] == '.'))
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#ifndef _LIBC
|
#ifndef _LIBC
|
||||||
# define __builtin_expect(expr, val) (expr)
|
# define __builtin_expect(expr, val) (expr)
|
||||||
|
# define __memmem memmem
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define RETURN_TYPE void *
|
#define RETURN_TYPE void *
|
||||||
@ -38,7 +39,7 @@
|
|||||||
if NEEDLE_LEN is 0, otherwise NULL if NEEDLE is not found in
|
if NEEDLE_LEN is 0, otherwise NULL if NEEDLE is not found in
|
||||||
HAYSTACK. */
|
HAYSTACK. */
|
||||||
void *
|
void *
|
||||||
memmem (const void *haystack_start, size_t haystack_len,
|
__memmem (const void *haystack_start, size_t haystack_len,
|
||||||
const void *needle_start, size_t needle_len)
|
const void *needle_start, size_t needle_len)
|
||||||
{
|
{
|
||||||
/* Abstract memory is considered to be an array of 'unsigned char' values,
|
/* Abstract memory is considered to be an array of 'unsigned char' values,
|
||||||
@ -73,6 +74,8 @@ memmem (const void *haystack_start, size_t haystack_len,
|
|||||||
else
|
else
|
||||||
return two_way_long_needle (haystack, haystack_len, needle, needle_len);
|
return two_way_long_needle (haystack, haystack_len, needle, needle_len);
|
||||||
}
|
}
|
||||||
libc_hidden_def (memmem)
|
libc_hidden_def (__memmem)
|
||||||
|
weak_alias (__memmem, memmem)
|
||||||
|
libc_hidden_weak (memmem)
|
||||||
|
|
||||||
#undef LONG_NEEDLE_THRESHOLD
|
#undef LONG_NEEDLE_THRESHOLD
|
||||||
|
Reference in New Issue
Block a user