+2017-03-13 Wilco Dijkstra <wdijkstr@arm.com>
+
+ [BZ #15105]
+ [BZ #19463]
+ * elf/dl-cache.c (_dl_load_cache_lookup): Use __strdup.
+ * inet/rcmd.c (rcmd_af): Likewise.
+ * inet/rexec.c (rexec_af): Likewise.
+ * intl/dcigettext.c (_LIBC): Likewise.
+ * intl/finddomain.c (_nl_find_domain): Use strdup expansion.
+ * locale/loadarchive.c (_nl_load_locale_from_archive): Use __strdup.
+ * locale/setlocale.c (setlocale): Likewise.
+ * posix/spawn_faction_addopen.c
+ (posix_spawn_file_actions_addopen): Likewise.
+ * stdlib/putenv.c (putenv): Use __strndup.
+ * sunrpc/svc_simple.c (__registerrpc): Use __strdup.
+ * sysdeps/posix/getaddrinfo.c (gaih_inet): Use __strdup/__strndup.
+ * include/stdlib.h (__need_malloc_and_calloc): Remove uses.
+ (__Need_M_And_C) Remove define/undef.
+ * stdlib/stdlib.h (__need_malloc_and_calloc): Remove uses.
+ (__malloc_and_calloc_defined): Remove define.
+ * string/bits/string2.h (__strdup): Remove define.
+ (strdup): Likewise.
+ (__strndup): Likewise.
+ (strndup): Likewise.
+
2017-03-13 Joseph Myers <joseph@codesourcery.com>
* sysdeps/unix/sysv/linux/bits/in.h (IPV6_AUTOFLOWLABEL): New
char *temp;
temp = alloca (strlen (best) + 1);
strcpy (temp, best);
- return strdup (temp);
+ return __strdup (temp);
}
#ifndef MAP_COPY
#ifndef _STDLIB_H
-#ifdef __need_malloc_and_calloc
-#define __Need_M_And_C
-#endif
-
#ifndef _ISOMAC
# include <stddef.h>
#endif
#include <stdlib/stdlib.h>
/* Now define the internal interfaces. */
-#if !defined __Need_M_And_C && !defined _ISOMAC
+#if !defined _ISOMAC
# include <sys/stat.h>
__BEGIN_DECLS
#endif
-#undef __Need_M_And_C
-
#endif /* include/stdlib.h */
if (res->ai_canonname){
free (ahostbuf);
- ahostbuf = strdup (res->ai_canonname);
+ ahostbuf = __strdup (res->ai_canonname);
if (ahostbuf == NULL) {
__fxprintf(NULL, "%s",
_("rcmd: Cannot allocate memory\n"));
if (res0->ai_canonname){
free (ahostbuf);
- ahostbuf = strdup (res0->ai_canonname);
+ ahostbuf = __strdup (res0->ai_canonname);
if (ahostbuf == NULL) {
perror ("rexec: strdup");
return (-1);
/* Rename the non ANSI C functions. This is required by the standard
because some ANSI C functions will require linking with this object
file and the name space must not be polluted. */
+# define strdup __strdup
# define getcwd __getcwd
# ifndef stpcpy
# define stpcpy __stpcpy
alias_value = _nl_expand_alias (locale);
if (alias_value != NULL)
{
-#if defined _LIBC || defined HAVE_STRDUP
- locale = strdup (alias_value);
- if (locale == NULL)
- return NULL;
-#else
size_t len = strlen (alias_value) + 1;
locale = (char *) malloc (len);
if (locale == NULL)
return NULL;
memcpy (locale, alias_value, len);
-#endif
}
/* Now we determine the single parts of the locale name. First
if (__glibc_unlikely (lia == NULL))
return NULL;
- lia->name = strdup (*namep);
+ lia->name = __strdup (*namep);
if (__glibc_unlikely (lia->name == NULL))
{
free (lia);
if (__glibc_unlikely (strchr (locale, ';') != NULL))
{
/* This is a composite name. Make a copy and split it up. */
- locale_copy = strdup (locale);
+ locale_copy = __strdup (locale);
if (__glibc_unlikely (locale_copy == NULL))
{
__libc_rwlock_unlock (__libc_setlocale_lock);
if (!__spawn_valid_fd (fd))
return EBADF;
- char *path_copy = strdup (path);
+ char *path_copy = __strdup (path);
if (path_copy == NULL)
return ENOMEM;
int use_malloc = !__libc_use_alloca (name_end - string + 1);
if (__builtin_expect (use_malloc, 0))
{
- name = strndup (string, name_end - string);
+ name = __strndup (string, name_end - string);
if (name == NULL)
return -1;
}
#include <bits/libc-header-start.h>
/* Get size_t, wchar_t and NULL from <stddef.h>. */
-#define __need_size_t
-#ifndef __need_malloc_and_calloc
-# define __need_wchar_t
-# define __need_NULL
-#endif
+#define __need_size_t
+#define __need_wchar_t
+#define __need_NULL
#include <stddef.h>
__BEGIN_DECLS
-#ifndef __need_malloc_and_calloc
#define _STDLIB_H 1
#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) && !defined _SYS_WAIT_H
# endif /* Use misc. */
#endif /* Use misc or X/Open. */
-#endif /* don't just need malloc and calloc */
-
-#ifndef __malloc_and_calloc_defined
-# define __malloc_and_calloc_defined
__BEGIN_NAMESPACE_STD
/* Allocate SIZE bytes of memory. */
extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
extern void *calloc (size_t __nmemb, size_t __size)
__THROW __attribute_malloc__ __wur;
__END_NAMESPACE_STD
-#endif
-#ifndef __need_malloc_and_calloc
__BEGIN_NAMESPACE_STD
/* Re-allocate the previously allocated block
in PTR, making the new block SIZE bytes long. */
# include <bits/stdlib-ldbl.h>
#endif
-#endif /* don't just need malloc and calloc */
-#undef __need_malloc_and_calloc
-
__END_DECLS
#endif /* stdlib.h */
#endif
-/* We need the memory allocation functions for inline strdup().
- Referring to stdlib.h (even minimally) is not allowed
- in any of the tight standards compliant modes. */
-#ifdef __USE_MISC
-
-# if !defined _HAVE_STRING_ARCH_strdup || !defined _HAVE_STRING_ARCH_strndup
-# define __need_malloc_and_calloc
-# include <stdlib.h>
-# endif
-
-# ifndef _HAVE_STRING_ARCH_strdup
-
-extern char *__strdup (const char *__string) __THROW __attribute_malloc__;
-# define __strdup(s) \
- (__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s) \
- ? (((const char *) (s))[0] == '\0' \
- ? (char *) calloc ((size_t) 1, (size_t) 1) \
- : ({ size_t __len = strlen (s) + 1; \
- char *__retval = (char *) malloc (__len); \
- if (__retval != NULL) \
- __retval = (char *) memcpy (__retval, s, __len); \
- __retval; })) \
- : __strdup (s)))
-
-# if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-# define strdup(s) __strdup (s)
-# endif
-# endif
-
-# ifndef _HAVE_STRING_ARCH_strndup
-
-extern char *__strndup (const char *__string, size_t __n)
- __THROW __attribute_malloc__;
-# define __strndup(s, n) \
- (__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s) \
- ? (((const char *) (s))[0] == '\0' \
- ? (char *) calloc ((size_t) 1, (size_t) 1) \
- : ({ size_t __len = strlen (s) + 1; \
- size_t __n = (n); \
- char *__retval; \
- if (__n < __len) \
- __len = __n + 1; \
- __retval = (char *) malloc (__len); \
- if (__retval != NULL) \
- { \
- __retval[__len - 1] = '\0'; \
- __retval = (char *) memcpy (__retval, s, \
- __len - 1); \
- } \
- __retval; })) \
- : __strndup (s, n)))
-
-# ifdef __USE_XOPEN2K8
-# define strndup(s, n) __strndup (s, n)
-# endif
-# endif
-
-#endif /* Use misc. or use GNU. */
-
#ifndef _FORCE_INLINES
# undef __STRING_INLINE
#endif
transp = svcudp_create (RPC_ANYSOCK);
if (transp == NULL)
{
- buf = strdup (_("couldn't create an rpc server\n"));
+ buf = __strdup (_("couldn't create an rpc server\n"));
goto err_out;
}
}
pl = (struct proglst_ *) malloc (sizeof (struct proglst_));
if (pl == NULL)
{
- buf = strdup (_("registerrpc: out of memory\n"));
+ buf = __strdup (_("registerrpc: out of memory\n"));
goto err_out;
}
pl->p_progname = progname;
}
else
{
- namebuf = strndup (name, scope_delim - name);
+ namebuf = __strndup (name, scope_delim - name);
if (namebuf == NULL)
{
assert (!malloc_name);
malloc_canonbuf = false;
else
{
- canon = strdup (canon);
+ canon = __strdup (canon);
if (canon == NULL)
{
result = -EAI_MEMORY;