Blame SOURCES/memstomp-rh1093173.patch

a9fe34
*** a/Makefile.am	2014-05-29 10:40:14.997714171 -0600
a9fe34
--- b/Makefile.am	2014-05-29 12:42:18.358166208 -0600
a9fe34
*************** libmemstomp_la_LIBADD = \
a9fe34
*** 53,58 ****
a9fe34
--- 53,60 ----
a9fe34
  	-ldl
a9fe34
  libmemstomp_la_CFLAGS = \
a9fe34
  	$(PTHREAD_CFLAGS) \
a9fe34
+ 	-fno-tree-vrp \
a9fe34
+ 	-fno-delete-null-pointer-checks \
a9fe34
  	-DSONAME=\"libmemstomp.so\"
a9fe34
  
a9fe34
  libmemstomp_backtrace_symbols_la_SOURCES = \
a9fe34
*************** libmemstomp_backtrace_symbols_la_LIBADD
a9fe34
*** 68,74 ****
a9fe34
  	-lrt \
a9fe34
  	-ldl
a9fe34
  libmemstomp_backtrace_symbols_la_CFLAGS = \
a9fe34
! 	$(PTHREAD_CFLAGS)
a9fe34
  
a9fe34
  memstomp: memstomp.in Makefile
a9fe34
  	sed -e 's,@PACKAGE_STRING\@,$(PACKAGE_STRING),g' \
a9fe34
--- 70,76 ----
a9fe34
  	-lrt \
a9fe34
  	-ldl
a9fe34
  libmemstomp_backtrace_symbols_la_CFLAGS = \
a9fe34
! 	$(PTHREAD_CFLAGS) 
a9fe34
  
a9fe34
  memstomp: memstomp.in Makefile
a9fe34
  	sed -e 's,@PACKAGE_STRING\@,$(PACKAGE_STRING),g' \
a9fe34
*** a/memstomp.c	2014-05-29 10:40:15.016714123 -0600
a9fe34
--- b/memstomp.c	2014-05-29 13:59:20.314343481 -0600
a9fe34
***************
a9fe34
*** 62,67 ****
a9fe34
--- 62,79 ----
a9fe34
  #define likely(x)	__builtin_expect(!!(x), 1)
a9fe34
  #define unlikely(x)	__builtin_expect(!!(x), 0)
a9fe34
  
a9fe34
+ #undef strcmp
a9fe34
+ #undef strncmp
a9fe34
+ #undef strdup
a9fe34
+ #undef strndup
a9fe34
+ #undef strchr
a9fe34
+ #undef strrchr
a9fe34
+ #undef strcspn
a9fe34
+ #undef strspn
a9fe34
+ #undef strpbrk
a9fe34
+ #undef strtok_r
a9fe34
+ #undef memcmp
a9fe34
+ 
a9fe34
  static bool abrt_trap = false;
a9fe34
  
a9fe34
  static bool quiet_mode = false;
a9fe34
*************** static void warn_copylap(void * dest, co
a9fe34
*** 316,321 ****
a9fe34
--- 328,356 ----
a9fe34
  	free(info);
a9fe34
  }
a9fe34
  
a9fe34
+ static void warn_null(char const *name)
a9fe34
+ {
a9fe34
+ 	char prname[17];
a9fe34
+ 	char buf[160];
a9fe34
+ 
a9fe34
+ /* Avoid fprintf which is not async signal safe.  fprintf may call malloc,
a9fe34
+  * which may experience trouble if the bad memcpy was called from a signal
a9fe34
+  * handler whose invoking signal interrupted malloc.
a9fe34
+  */
a9fe34
+ 	int const j = snprintf(buf, sizeof(buf),
a9fe34
+ 		"\n\n%s NULL pointer %s(%d)\n",
a9fe34
+ 		name, get_prname(prname), getpid());
a9fe34
+ 	write(STDERR_FILENO, buf, umin(j, sizeof(buf)));
a9fe34
+ 	
a9fe34
+ /* If generate_stacktrace() indirectly invokes malloc (such as via libbfd),
a9fe34
+  * then this is not async signal safe.  But the write() above will produce
a9fe34
+  * some evidence before any possible trouble below.
a9fe34
+  */
a9fe34
+ 	char *const info = generate_stacktrace();
a9fe34
+ 	fprintf(stderr, "%s", info);
a9fe34
+ 	free(info);
a9fe34
+ }
a9fe34
+ 
a9fe34
  static void *copy(void *dest, void const *src, size_t count, char const *name)
a9fe34
  {
a9fe34
  	size_t d = (char *)dest - (char *)src;
a9fe34
*************** static void *copy(void *dest, void const
a9fe34
*** 326,331 ****
a9fe34
--- 361,367 ----
a9fe34
  		/* report the overlap */
a9fe34
  		warn_copylap(dest, src, count, name);
a9fe34
  	}
a9fe34
+ 
a9fe34
  	/* be safe use memmove */
a9fe34
  	return memmove(dest, src, count);
a9fe34
  }
a9fe34
*************** char *stpncpy(char *dst, char const *src
a9fe34
*** 496,498 ****
a9fe34
--- 532,956 ----
a9fe34
  
a9fe34
  /* XXX wcstok: Ugly! */
a9fe34
  
a9fe34
+ /* All the interposition routines below are just checking for NULL
a9fe34
+    arguments when ISO demands they be non-null.  */
a9fe34
+ 
a9fe34
+ void *memmove (void *dest, const void *src, size_t n)
a9fe34
+ {
a9fe34
+   static void * (*real_memmove)(void *, const void *, size_t) = NULL;
a9fe34
+   if (!real_memmove)
a9fe34
+ 	real_memmove = dlsym(RTLD_NEXT, "memmove");
a9fe34
+ 
a9fe34
+   if (unlikely (dest == NULL || src == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("memmove");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_memmove (dest, src, n);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ int memcmp (const void *__s1, const void *__s2, size_t __n)
a9fe34
+ {
a9fe34
+   static int (*real_memcmp)(const void *, const void *, size_t) = NULL;
a9fe34
+   if (!real_memcmp)
a9fe34
+ 	real_memcmp = dlsym(RTLD_NEXT, "memcmp");
a9fe34
+ 
a9fe34
+   if (unlikely (__s1 == NULL || __s2 == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("memcmp");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_memcmp (__s1, __s2, __n);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ int strcmp (const char *__s1, const char *__s2)
a9fe34
+ {
a9fe34
+   static int (*real_strcmp)(const char *, const char *) = NULL;
a9fe34
+   if (!real_strcmp)
a9fe34
+ 	real_strcmp = dlsym(RTLD_NEXT, "strcmp");
a9fe34
+ 
a9fe34
+   if (unlikely (__s1 == NULL || __s2 == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strcmp");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strcmp (__s1, __s2);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ int strncmp (const char *__s1, const char *__s2, size_t __n)
a9fe34
+ {
a9fe34
+   static int (*real_strncmp)(const char *, const char *, size_t) = NULL;
a9fe34
+   if (!real_strncmp)
a9fe34
+ 	real_strncmp = dlsym(RTLD_NEXT, "strncmp");
a9fe34
+ 
a9fe34
+   if (unlikely (__s1 == NULL || __s2 == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strncmp");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strncmp (__s1, __s2, __n);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ int strcoll (const char *__s1, const char *__s2)
a9fe34
+ {
a9fe34
+   static int (*real_strcoll)(const char *, const char *) = NULL;
a9fe34
+   if (!real_strcoll)
a9fe34
+ 	real_strcoll = dlsym(RTLD_NEXT, "strcoll");
a9fe34
+ 
a9fe34
+   if (unlikely (__s1 == NULL || __s2 == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strcoll");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strcoll (__s1, __s2);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ int strcoll_l (const char *__s1, const char *__s2, __locale_t __l)
a9fe34
+ {
a9fe34
+   static int (*real_strcoll_l)(const char *, const char *, __locale_t) = NULL;
a9fe34
+   if (!real_strcoll_l)
a9fe34
+ 	real_strcoll_l = dlsym(RTLD_NEXT, "strcoll_l");
a9fe34
+ 
a9fe34
+   if (unlikely (__s1 == NULL || __s2 == NULL || __l == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strcoll_l");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strcoll_l (__s1, __s2, __l);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ size_t strxfrm (char *__dest, const char *__src, size_t __n)
a9fe34
+ {
a9fe34
+   static size_t (*real_strxfrm)(char *, const char *, size_t) = NULL;
a9fe34
+   if (!real_strxfrm)
a9fe34
+ 	real_strxfrm = dlsym(RTLD_NEXT, "strxfrm");
a9fe34
+ 
a9fe34
+   if (unlikely (__src == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strxfrm");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strxfrm (__dest, __src, __n);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ size_t strxfrm_l (char *__dest, const char *__src, size_t __n, __locale_t __l)
a9fe34
+ {
a9fe34
+   static size_t (*real_strxfrm_l)(char *, const char *, size_t, __locale_t) = NULL;
a9fe34
+   if (!real_strxfrm_l)
a9fe34
+ 	real_strxfrm_l = dlsym(RTLD_NEXT, "strxfrm_l");
a9fe34
+ 
a9fe34
+   if (unlikely (__src == NULL || __l == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strxfrm_l");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strxfrm_l (__dest, __src, __n, __l);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ 
a9fe34
+ void *memset (void *__s, int __c, size_t __n)
a9fe34
+ {
a9fe34
+   static void * (*real_memset)(void *, int, size_t) = NULL;
a9fe34
+   if (!real_memset)
a9fe34
+ 	real_memset = dlsym(RTLD_NEXT, "memset");
a9fe34
+ 
a9fe34
+   if (unlikely (__s == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("memset");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_memset (__s, __c, __n);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ void *memchr (const void *__s, int __c, size_t __n)
a9fe34
+ {
a9fe34
+   static void * (*real_memchr)(const void *, int, size_t) = NULL;
a9fe34
+   if (!real_memchr)
a9fe34
+ 	real_memchr = dlsym(RTLD_NEXT, "memchr");
a9fe34
+ 
a9fe34
+   if (unlikely (__s == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("memchr");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_memchr (__s, __c, __n);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ void *memrchr (const void *__s, int __c, size_t __n)
a9fe34
+ {
a9fe34
+   static void * (*real_memrchr)(const void *, int, size_t) = NULL;
a9fe34
+   if (!real_memrchr)
a9fe34
+ 	real_memrchr = dlsym(RTLD_NEXT, "memrchr");
a9fe34
+ 
a9fe34
+   if (unlikely (__s == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("memrchr");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_memrchr (__s, __c, __n);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ void *rawmemchr (const void *__s, int __c)
a9fe34
+ {
a9fe34
+   static void * (*real_rawmemchr)(const void *, int, size_t) = NULL;
a9fe34
+   if (!real_rawmemchr)
a9fe34
+ 	real_rawmemchr = dlsym(RTLD_NEXT, "rawmemchr");
a9fe34
+ 
a9fe34
+   if (unlikely (__s == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("rawmemchr");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_rawmemchr (__s, __c, __c);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ size_t strlen (const char *__s)
a9fe34
+ {
a9fe34
+   static size_t (*real_strlen)(const char *) = NULL;
a9fe34
+   if (!real_strlen)
a9fe34
+ 	real_strlen = dlsym(RTLD_NEXT, "strlen");
a9fe34
+ 
a9fe34
+   if (unlikely (__s == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strlen");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strlen (__s);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ char *strdup (const char *__s)
a9fe34
+ {
a9fe34
+   static char *(*real_strdup)(const char *) = NULL;
a9fe34
+   if (!real_strdup)
a9fe34
+ 	real_strdup = dlsym(RTLD_NEXT, "strdup");
a9fe34
+ 
a9fe34
+   if (unlikely (__s == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strdup");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strdup (__s);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ char *strndup (const char *__s, size_t __n)
a9fe34
+ {
a9fe34
+   static char *(*real_strndup)(const char *, size_t) = NULL;
a9fe34
+   if (!real_strndup)
a9fe34
+ 	real_strndup = dlsym(RTLD_NEXT, "strndup");
a9fe34
+ 
a9fe34
+   if (unlikely (__s == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strndup");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strndup (__s, __n);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ char *strchr (const char *__s, int __c)
a9fe34
+ {
a9fe34
+   static char * (*real_strchr)(const void *, int) = NULL;
a9fe34
+   if (!real_strchr)
a9fe34
+ 	real_strchr = dlsym(RTLD_NEXT, "strchr");
a9fe34
+ 
a9fe34
+   if (unlikely (__s == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strchr");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strchr (__s, __c);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ char *strrchr (const char *__s, int __c)
a9fe34
+ {
a9fe34
+   static char * (*real_strrchr)(const void *, int) = NULL;
a9fe34
+   if (!real_strrchr)
a9fe34
+ 	real_strrchr = dlsym(RTLD_NEXT, "strrchr");
a9fe34
+ 
a9fe34
+   if (unlikely (__s == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strrchr");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strrchr (__s, __c);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ char *strchrnul (const char *__s, int __c)
a9fe34
+ {
a9fe34
+   static char * (*real_strchrnul)(const void *, int) = NULL;
a9fe34
+   if (!real_strchrnul)
a9fe34
+ 	real_strchrnul = dlsym(RTLD_NEXT, "strchrnul");
a9fe34
+ 
a9fe34
+   if (unlikely (__s == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strchrnul");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strchrnul (__s, __c);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ size_t strcspn (const char *__s, const char *__reject)
a9fe34
+ {
a9fe34
+   static size_t (*real_strcspn)(const void *, const char *) = NULL;
a9fe34
+   if (!real_strcspn)
a9fe34
+ 	real_strcspn = dlsym(RTLD_NEXT, "strcspn");
a9fe34
+ 
a9fe34
+   if (unlikely (__s == NULL || __reject == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strcspn");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strcspn (__s, __reject);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ size_t strspn (const char *__s, const char *__accept)
a9fe34
+ {
a9fe34
+   static size_t (*real_strspn)(const void *, const char *) = NULL;
a9fe34
+   if (!real_strspn)
a9fe34
+ 	real_strspn = dlsym(RTLD_NEXT, "strspn");
a9fe34
+ 
a9fe34
+   if (unlikely (__s == NULL || __accept == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strspn");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strspn (__s, __accept);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ char * strpbrk (const char *__s, const char *__accept)
a9fe34
+ {
a9fe34
+   static char * (*real_strpbrk)(const void *, const char *) = NULL;
a9fe34
+   if (!real_strpbrk)
a9fe34
+ 	real_strpbrk = dlsym(RTLD_NEXT, "strpbrk");
a9fe34
+ 
a9fe34
+   if (unlikely (__s == NULL || __accept == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strpbrk");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strpbrk (__s, __accept);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ char * strstr (const char *__haystack, const char *__needle)
a9fe34
+ {
a9fe34
+   static char * (*real_strstr)(const void *, const char *) = NULL;
a9fe34
+   if (!real_strstr)
a9fe34
+ 	real_strstr = dlsym(RTLD_NEXT, "strstr");
a9fe34
+ 
a9fe34
+   if (unlikely (__haystack == NULL || __needle == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strstr");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strstr (__haystack, __needle);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ char *strcasestr (const char *__haystack, const char *__needle)
a9fe34
+ {
a9fe34
+   static char * (*real_strcasestr)(const void *, const char *) = NULL;
a9fe34
+   if (!real_strcasestr)
a9fe34
+ 	real_strcasestr = dlsym(RTLD_NEXT, "strcasestr");
a9fe34
+ 
a9fe34
+   if (unlikely (__haystack == NULL || __needle == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strcasestr");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strcasestr (__haystack, __needle);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ void *memmem (const void *__haystack, size_t __haystacklen,
a9fe34
+ 	      const void *__needle, size_t __needlelen)
a9fe34
+ {
a9fe34
+   static char * (*real_memmem)(const void *, size_t, const char *, size_t) = NULL;
a9fe34
+   if (!real_memmem)
a9fe34
+ 	real_memmem = dlsym(RTLD_NEXT, "memmem");
a9fe34
+ 
a9fe34
+   if (unlikely (__haystack == NULL || __needle == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("memmem");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_memmem (__haystack, __haystacklen, __needle, __needlelen);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ char * strtok (char *__s, const char *__delim)
a9fe34
+ {
a9fe34
+   static char * (*real_strtok)(void *, const char *) = NULL;
a9fe34
+   if (!real_strtok)
a9fe34
+ 	real_strtok = dlsym(RTLD_NEXT, "strtok");
a9fe34
+ 
a9fe34
+   if (unlikely (__delim == NULL)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strtok");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strtok (__s, __delim);
a9fe34
+ }
a9fe34
+ 
a9fe34
+ 
a9fe34
+ char * strtok_r (char *__s, const char *__delim, char **__save_ptr)
a9fe34
+ {
a9fe34
+   static char * (*real_strtok_r)(void *, const char *, char **) = NULL;
a9fe34
+   if (!real_strtok_r)
a9fe34
+ 	real_strtok_r = dlsym(RTLD_NEXT, "strtok_r");
a9fe34
+ 
a9fe34
+   if (unlikely (__delim == NULL || __save_ptr)) {
a9fe34
+ 	if (abrt_trap) ABRT_TRAP;
a9fe34
+ 	/* report the NULL pointer */
a9fe34
+ 	warn_null("strtok_r");
a9fe34
+ 	return 0;
a9fe34
+   }
a9fe34
+ 
a9fe34
+   return real_strtok_r (__s, __delim, __save_ptr);
a9fe34
+ }
a9fe34
+ 
a9fe34
diff -Nrup a/testsuite/memstomp.null/memccpy.c b/testsuite/memstomp.null/memccpy.c
a9fe34
--- a/testsuite/memstomp.null/memccpy.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/memccpy.c	2014-05-29 12:42:18.358166208 -0600
a9fe34
@@ -0,0 +1,20 @@
a9fe34
+#define _GNU_SOURCE
a9fe34
+#include <string.h>
a9fe34
+#include <wchar.h>
a9fe34
+
a9fe34
+#ifndef MEMCCPY
a9fe34
+#define MEMCCPY memccpy
a9fe34
+#define TYPE char
a9fe34
+#endif
a9fe34
+
a9fe34
+TYPE arr1[10] = {0};
a9fe34
+TYPE arr2[10] = {0};
a9fe34
+TYPE *p1 = &arr1[0];
a9fe34
+TYPE *p2 = &arr2[1];
a9fe34
+size_t count = 9;
a9fe34
+main ()
a9fe34
+{
a9fe34
+  MEMCCPY (NULL, NULL, -1, 0);
a9fe34
+}
a9fe34
+
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/memchr.c b/testsuite/memstomp.null/memchr.c
a9fe34
--- a/testsuite/memstomp.null/memchr.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/memchr.c	2014-05-29 14:09:04.667841941 -0600
a9fe34
@@ -0,0 +1,4 @@
a9fe34
+#define MEMSET memchr
a9fe34
+#define TYPE char
a9fe34
+#include "memset.c"
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/memcmp.c b/testsuite/memstomp.null/memcmp.c
a9fe34
--- a/testsuite/memstomp.null/memcmp.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/memcmp.c	2014-05-29 13:57:53.098567650 -0600
a9fe34
@@ -0,0 +1,3 @@
a9fe34
+#define MEMCPY memcmp
a9fe34
+#define TYPE char
a9fe34
+#include "memcpy.c"
a9fe34
diff -Nrup a/testsuite/memstomp.null/memcpy.c b/testsuite/memstomp.null/memcpy.c
a9fe34
--- a/testsuite/memstomp.null/memcpy.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/memcpy.c	2014-05-29 14:01:34.002999896 -0600
a9fe34
@@ -0,0 +1,20 @@
a9fe34
+#define _GNU_SOURCE
a9fe34
+#include <string.h>
a9fe34
+#include <wchar.h>
a9fe34
+
a9fe34
+#ifndef MEMCPY
a9fe34
+#define MEMCPY memcpy
a9fe34
+#define TYPE char
a9fe34
+#endif
a9fe34
+
a9fe34
+TYPE arr1[10] = {0};
a9fe34
+TYPE arr2[10] = {0};
a9fe34
+TYPE *p1 = &arr1[0];
a9fe34
+TYPE *p2 = &arr2[1];
a9fe34
+size_t count = 9;
a9fe34
+main ()
a9fe34
+{
a9fe34
+  return MEMCPY (NULL, NULL, 0) == 0 ;
a9fe34
+}
a9fe34
+
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/memmem.c b/testsuite/memstomp.null/memmem.c
a9fe34
--- a/testsuite/memstomp.null/memmem.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/memmem.c	2014-05-29 14:18:37.569363960 -0600
a9fe34
@@ -0,0 +1,20 @@
a9fe34
+#define _GNU_SOURCE
a9fe34
+#include <string.h>
a9fe34
+#include <wchar.h>
a9fe34
+
a9fe34
+#ifndef MEMMEM
a9fe34
+#define MEMMEM memmem
a9fe34
+#define TYPE char
a9fe34
+#endif
a9fe34
+
a9fe34
+TYPE arr1[10] = {0};
a9fe34
+TYPE arr2[10] = {0};
a9fe34
+TYPE *p1 = &arr1[0];
a9fe34
+TYPE *p2 = &arr2[1];
a9fe34
+size_t count = 9;
a9fe34
+main ()
a9fe34
+{
a9fe34
+  return MEMMEM (NULL, 0, NULL, 0) == 0 ;
a9fe34
+}
a9fe34
+
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/memmove.c b/testsuite/memstomp.null/memmove.c
a9fe34
--- a/testsuite/memstomp.null/memmove.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/memmove.c	2014-05-29 13:57:29.563628151 -0600
a9fe34
@@ -0,0 +1,3 @@
a9fe34
+#define MEMCPY memmove
a9fe34
+#define TYPE char
a9fe34
+#include "memcpy.c"
a9fe34
diff -Nrup a/testsuite/memstomp.null/mempcpy.c b/testsuite/memstomp.null/mempcpy.c
a9fe34
--- a/testsuite/memstomp.null/mempcpy.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/mempcpy.c	2014-05-29 12:42:18.358166208 -0600
a9fe34
@@ -0,0 +1,3 @@
a9fe34
+#define MEMCPY mempcpy
a9fe34
+#define TYPE char
a9fe34
+#include "memcpy.c"
a9fe34
diff -Nrup a/testsuite/memstomp.null/memrchr.c b/testsuite/memstomp.null/memrchr.c
a9fe34
--- a/testsuite/memstomp.null/memrchr.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/memrchr.c	2014-05-29 14:09:22.122797099 -0600
a9fe34
@@ -0,0 +1,4 @@
a9fe34
+#define MEMSET memrchr
a9fe34
+#define TYPE char
a9fe34
+#include "memset.c"
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/memset.c b/testsuite/memstomp.null/memset.c
a9fe34
--- a/testsuite/memstomp.null/memset.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/memset.c	2014-05-29 14:08:06.411991603 -0600
a9fe34
@@ -0,0 +1,20 @@
a9fe34
+#define _GNU_SOURCE
a9fe34
+#include <string.h>
a9fe34
+#include <wchar.h>
a9fe34
+
a9fe34
+#ifndef MEMSET
a9fe34
+#define MEMSET memset
a9fe34
+#define TYPE char
a9fe34
+#endif
a9fe34
+
a9fe34
+TYPE arr1[10] = {0};
a9fe34
+TYPE arr2[10] = {0};
a9fe34
+TYPE *p1 = &arr1[0];
a9fe34
+TYPE *p2 = &arr2[1];
a9fe34
+size_t count = 9;
a9fe34
+main ()
a9fe34
+{
a9fe34
+  return MEMSET (NULL, -1, 0) == 0;
a9fe34
+}
a9fe34
+
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/null.exp b/testsuite/memstomp.null/null.exp
a9fe34
--- a/testsuite/memstomp.null/null.exp	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/null.exp	2014-05-29 12:42:18.358166208 -0600
a9fe34
@@ -0,0 +1,59 @@
a9fe34
+# Copyright (C) 2013 Free Software Foundation, Inc.
a9fe34
+
a9fe34
+# This program is free software; you can redistribute it and/or modify
a9fe34
+# it under the terms of the GNU General Public License as published by
a9fe34
+# the Free Software Foundation; either version 3 of the License, or
a9fe34
+# (at your option) any later version.
a9fe34
+#
a9fe34
+# This program is distributed in the hope that it will be useful,
a9fe34
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
a9fe34
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a9fe34
+# GNU General Public License for more details.
a9fe34
+#
a9fe34
+# You should have received a copy of the GNU General Public License
a9fe34
+# along with GCC; see the file COPYING3.  If not see
a9fe34
+# <http://www.gnu.org/licenses/>.
a9fe34
+#
a9fe34
+# This was originally copied from GCC's dejagnu testing framework
a9fe34
+#
a9fe34
+
a9fe34
+load_lib memstomp.exp
a9fe34
+set memstomp [find_memstomp]
a9fe34
+set libmemstomp [find_libmemstomp]
a9fe34
+
a9fe34
+if $tracelevel then {
a9fe34
+    strace $tracelevel
a9fe34
+}
a9fe34
+
a9fe34
+#
a9fe34
+# main test loop
a9fe34
+#
a9fe34
+
a9fe34
+proc compile-and-execute { sources } {
a9fe34
+  global memstomp
a9fe34
+  global libmemstomp
a9fe34
+
a9fe34
+  set src [lindex $sources 0]
a9fe34
+
a9fe34
+  if {[catch {exec gcc -fno-builtin $src} results]} {
a9fe34
+    fail "$src compilation $results"
a9fe34
+  } else {
a9fe34
+    pass "$src compilation $results"
a9fe34
+  }
a9fe34
+
a9fe34
+  catch {exec /bin/bash -c "LD_PRELOAD=$libmemstomp $memstomp ./a.out"} results
a9fe34
+  if {[regexp "NULL pointer" $results]} {
a9fe34
+    pass "$src found NULL $results"
a9fe34
+  } else {
a9fe34
+    fail "$src found NULL $results"
a9fe34
+  }
a9fe34
+}
a9fe34
+
a9fe34
+foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
a9fe34
+    # If we're only testing specific files and this isn't one of them, skip it.
a9fe34
+    if ![runtest_file_p $runtests $src] then {
a9fe34
+        continue
a9fe34
+    }
a9fe34
+
a9fe34
+   compile-and-execute $src
a9fe34
+}
a9fe34
diff -Nrup a/testsuite/memstomp.null/rawmemchr.c b/testsuite/memstomp.null/rawmemchr.c
a9fe34
--- a/testsuite/memstomp.null/rawmemchr.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/rawmemchr.c	2014-05-29 14:10:36.610605748 -0600
a9fe34
@@ -0,0 +1,20 @@
a9fe34
+#define _GNU_SOURCE
a9fe34
+#include <string.h>
a9fe34
+#include <wchar.h>
a9fe34
+
a9fe34
+#ifndef RAWMEMCHR
a9fe34
+#define RAWMEMCHR rawmemchr
a9fe34
+#define TYPE char
a9fe34
+#endif
a9fe34
+
a9fe34
+TYPE arr1[10] = {0};
a9fe34
+TYPE arr2[10] = {0};
a9fe34
+TYPE *p1 = &arr1[0];
a9fe34
+TYPE *p2 = &arr2[1];
a9fe34
+size_t count = 9;
a9fe34
+main ()
a9fe34
+{
a9fe34
+  return RAWMEMCHR (NULL, 0) == 0;
a9fe34
+}
a9fe34
+
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/stpcpy.c b/testsuite/memstomp.null/stpcpy.c
a9fe34
--- a/testsuite/memstomp.null/stpcpy.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/stpcpy.c	2014-05-29 12:42:18.358166208 -0600
a9fe34
@@ -0,0 +1,2 @@
a9fe34
+#define STRCPY stpcpy
a9fe34
+#include "strcpy.c"
a9fe34
diff -Nrup a/testsuite/memstomp.null/stpncpy.c b/testsuite/memstomp.null/stpncpy.c
a9fe34
--- a/testsuite/memstomp.null/stpncpy.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/stpncpy.c	2014-05-29 12:42:18.358166208 -0600
a9fe34
@@ -0,0 +1,2 @@
a9fe34
+#define STRNCPY stpncpy
a9fe34
+#include "strncpy.c"
a9fe34
diff -Nrup a/testsuite/memstomp.null/strcasestr.c b/testsuite/memstomp.null/strcasestr.c
a9fe34
--- a/testsuite/memstomp.null/strcasestr.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strcasestr.c	2014-05-29 14:18:59.099308034 -0600
a9fe34
@@ -0,0 +1,2 @@
a9fe34
+#define STRCMP strstr
a9fe34
+#include "strcmp.c"
a9fe34
diff -Nrup a/testsuite/memstomp.null/strcat.c b/testsuite/memstomp.null/strcat.c
a9fe34
--- a/testsuite/memstomp.null/strcat.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strcat.c	2014-05-29 12:42:18.359166205 -0600
a9fe34
@@ -0,0 +1,2 @@
a9fe34
+#define STRCPY strcat
a9fe34
+#include "strcpy.c"
a9fe34
diff -Nrup a/testsuite/memstomp.null/strchr.c b/testsuite/memstomp.null/strchr.c
a9fe34
--- a/testsuite/memstomp.null/strchr.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strchr.c	2014-05-29 14:13:39.929134865 -0600
a9fe34
@@ -0,0 +1,4 @@
a9fe34
+#define RAWMEMCHR strchr
a9fe34
+#define TYPE char
a9fe34
+#include "rawmemchr.c"
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/strchrnul.c b/testsuite/memstomp.null/strchrnul.c
a9fe34
--- a/testsuite/memstomp.null/strchrnul.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strchrnul.c	2014-05-29 14:15:17.983882584 -0600
a9fe34
@@ -0,0 +1,4 @@
a9fe34
+#define RAWMEMCHR strrchr
a9fe34
+#define TYPE char
a9fe34
+#include "rawmemchr.c"
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/strcmp.c b/testsuite/memstomp.null/strcmp.c
a9fe34
--- a/testsuite/memstomp.null/strcmp.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strcmp.c	2014-05-29 14:17:21.903560538 -0600
a9fe34
@@ -0,0 +1,19 @@
a9fe34
+#define _GNU_SOURCE
a9fe34
+#include <string.h>
a9fe34
+#include <wchar.h>
a9fe34
+
a9fe34
+#ifndef STRCMP
a9fe34
+#define STRCMP strcmp
a9fe34
+#endif
a9fe34
+
a9fe34
+
a9fe34
+char arr1[32] = "this is a test";
a9fe34
+char arr2[32] = "this is a test";
a9fe34
+char *p1 = &arr1[0];
a9fe34
+char *p2 = &arr2[1];
a9fe34
+main ()
a9fe34
+{
a9fe34
+  return STRCMP (NULL, NULL) == 0;
a9fe34
+}
a9fe34
+
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/strcoll.c b/testsuite/memstomp.null/strcoll.c
a9fe34
--- a/testsuite/memstomp.null/strcoll.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strcoll.c	2014-05-29 14:04:39.735522619 -0600
a9fe34
@@ -0,0 +1,2 @@
a9fe34
+#define STRNCPY strcoll
a9fe34
+#include "strcmp.c"
a9fe34
Binary files a/testsuite/memstomp.null/.strcoll.c.swp and b/testsuite/memstomp.null/.strcoll.c.swp differ
a9fe34
diff -Nrup a/testsuite/memstomp.null/strcoll_l.c b/testsuite/memstomp.null/strcoll_l.c
a9fe34
--- a/testsuite/memstomp.null/strcoll_l.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strcoll_l.c	2014-05-29 14:05:22.181413555 -0600
a9fe34
@@ -0,0 +1,19 @@
a9fe34
+#define _GNU_SOURCE
a9fe34
+#include <string.h>
a9fe34
+#include <wchar.h>
a9fe34
+
a9fe34
+#ifndef STRCMP
a9fe34
+#define STRCMP strcoll_l
a9fe34
+#endif
a9fe34
+
a9fe34
+
a9fe34
+char arr1[32] = "this is a test";
a9fe34
+char arr2[32] = "this is a test";
a9fe34
+char *p1 = &arr1[0];
a9fe34
+char *p2 = &arr2[1];
a9fe34
+main ()
a9fe34
+{
a9fe34
+  return STRCMP (NULL, NULL, NULL);
a9fe34
+}
a9fe34
+
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/strcpy.c b/testsuite/memstomp.null/strcpy.c
a9fe34
--- a/testsuite/memstomp.null/strcpy.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strcpy.c	2014-05-29 12:42:18.359166205 -0600
a9fe34
@@ -0,0 +1,19 @@
a9fe34
+#define _GNU_SOURCE
a9fe34
+#include <string.h>
a9fe34
+#include <wchar.h>
a9fe34
+
a9fe34
+#ifndef STRCPY
a9fe34
+#define STRCPY strcpy
a9fe34
+#endif
a9fe34
+
a9fe34
+
a9fe34
+char arr1[32] = "this is a test";
a9fe34
+char arr2[32] = "this is a test";
a9fe34
+char *p1 = &arr1[0];
a9fe34
+char *p2 = &arr2[1];
a9fe34
+main ()
a9fe34
+{
a9fe34
+  STRCPY (NULL, NULL);
a9fe34
+}
a9fe34
+
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/strcspn.c b/testsuite/memstomp.null/strcspn.c
a9fe34
--- a/testsuite/memstomp.null/strcspn.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strcspn.c	2014-05-29 14:16:12.219741618 -0600
a9fe34
@@ -0,0 +1,2 @@
a9fe34
+#define STRCMP strcspn
a9fe34
+#include "strcmp.c"
a9fe34
diff -Nrup a/testsuite/memstomp.null/strdup.c b/testsuite/memstomp.null/strdup.c
a9fe34
--- a/testsuite/memstomp.null/strdup.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strdup.c	2014-05-29 14:12:20.521338829 -0600
a9fe34
@@ -0,0 +1,3 @@
a9fe34
+#define STRLEN strdup
a9fe34
+#define TYPE char
a9fe34
+#include "strlen.c"
a9fe34
diff -Nrup a/testsuite/memstomp.null/strlen.c b/testsuite/memstomp.null/strlen.c
a9fe34
--- a/testsuite/memstomp.null/strlen.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strlen.c	2014-05-29 14:12:28.969317129 -0600
a9fe34
@@ -0,0 +1,19 @@
a9fe34
+#define _GNU_SOURCE
a9fe34
+#include <string.h>
a9fe34
+#include <wchar.h>
a9fe34
+
a9fe34
+#ifndef STRLEN
a9fe34
+#define STRLEN strlen
a9fe34
+#endif
a9fe34
+
a9fe34
+
a9fe34
+char arr1[32] = "this is a test";
a9fe34
+char arr2[32] = "this is a test";
a9fe34
+char *p1 = &arr1[0];
a9fe34
+char *p2 = &arr2[1];
a9fe34
+main ()
a9fe34
+{
a9fe34
+  return STRLEN (NULL) == 0;
a9fe34
+}
a9fe34
+
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/strncat.c b/testsuite/memstomp.null/strncat.c
a9fe34
--- a/testsuite/memstomp.null/strncat.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strncat.c	2014-05-29 12:42:18.359166205 -0600
a9fe34
@@ -0,0 +1,2 @@
a9fe34
+#define STRNCPY strncat
a9fe34
+#include "strncpy.c"
a9fe34
diff -Nrup a/testsuite/memstomp.null/strncmp.c b/testsuite/memstomp.null/strncmp.c
a9fe34
--- a/testsuite/memstomp.null/strncmp.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strncmp.c	2014-05-29 14:03:31.222698668 -0600
a9fe34
@@ -0,0 +1,19 @@
a9fe34
+#define _GNU_SOURCE
a9fe34
+#include <string.h>
a9fe34
+#include <wchar.h>
a9fe34
+
a9fe34
+#ifndef STRNCMP
a9fe34
+#define STRNCMP strncmp
a9fe34
+#endif
a9fe34
+
a9fe34
+
a9fe34
+char arr1[32] = "this is a test";
a9fe34
+char arr2[32] = "this is a test";
a9fe34
+char *p1 = &arr1[0];
a9fe34
+char *p2 = &arr2[1];
a9fe34
+main ()
a9fe34
+{
a9fe34
+  return STRNCMP (NULL, NULL, 0);
a9fe34
+}
a9fe34
+
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/strncpy.c b/testsuite/memstomp.null/strncpy.c
a9fe34
--- a/testsuite/memstomp.null/strncpy.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strncpy.c	2014-05-29 12:42:18.359166205 -0600
a9fe34
@@ -0,0 +1,19 @@
a9fe34
+#define _GNU_SOURCE
a9fe34
+#include <string.h>
a9fe34
+#include <wchar.h>
a9fe34
+
a9fe34
+#ifndef STRNCPY
a9fe34
+#define STRNCPY strncpy
a9fe34
+#endif
a9fe34
+
a9fe34
+
a9fe34
+char arr1[32] = "this is a test";
a9fe34
+char arr2[32] = "this is a test";
a9fe34
+char *p1 = &arr1[0];
a9fe34
+char *p2 = &arr2[1];
a9fe34
+main ()
a9fe34
+{
a9fe34
+  STRNCPY (NULL, NULL, 0);
a9fe34
+}
a9fe34
+
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/strndup.c b/testsuite/memstomp.null/strndup.c
a9fe34
--- a/testsuite/memstomp.null/strndup.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strndup.c	2014-05-29 14:13:18.192190697 -0600
a9fe34
@@ -0,0 +1,4 @@
a9fe34
+#define RAWMEMCHR strndup
a9fe34
+#define TYPE char
a9fe34
+#include "rawmemchr.c"
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/strpbrk.c b/testsuite/memstomp.null/strpbrk.c
a9fe34
--- a/testsuite/memstomp.null/strpbrk.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strpbrk.c	2014-05-29 14:17:09.970591544 -0600
a9fe34
@@ -0,0 +1,2 @@
a9fe34
+#define STRCMP strpbrk
a9fe34
+#include "strcmp.c"
a9fe34
diff -Nrup a/testsuite/memstomp.null/strrchr.c b/testsuite/memstomp.null/strrchr.c
a9fe34
--- a/testsuite/memstomp.null/strrchr.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strrchr.c	2014-05-29 14:15:23.466868332 -0600
a9fe34
@@ -0,0 +1,4 @@
a9fe34
+#define RAWMEMCHR strchrnul
a9fe34
+#define TYPE char
a9fe34
+#include "rawmemchr.c"
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/strspn.c b/testsuite/memstomp.null/strspn.c
a9fe34
--- a/testsuite/memstomp.null/strspn.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strspn.c	2014-05-29 14:16:33.880685326 -0600
a9fe34
@@ -0,0 +1,2 @@
a9fe34
+#define STRCMP strspn
a9fe34
+#include "strcmp.c"
a9fe34
diff -Nrup a/testsuite/memstomp.null/strstr.c b/testsuite/memstomp.null/strstr.c
a9fe34
--- a/testsuite/memstomp.null/strstr.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strstr.c	2014-05-29 14:16:56.195627338 -0600
a9fe34
@@ -0,0 +1,2 @@
a9fe34
+#define STRCMP strstr
a9fe34
+#include "strcmp.c"
a9fe34
diff -Nrup a/testsuite/memstomp.null/strtok.c b/testsuite/memstomp.null/strtok.c
a9fe34
--- a/testsuite/memstomp.null/strtok.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strtok.c	2014-05-29 14:19:10.868277465 -0600
a9fe34
@@ -0,0 +1,2 @@
a9fe34
+#define STRCMP strtok
a9fe34
+#include "strcmp.c"
a9fe34
diff -Nrup a/testsuite/memstomp.null/strtok_r.c b/testsuite/memstomp.null/strtok_r.c
a9fe34
--- a/testsuite/memstomp.null/strtok_r.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strtok_r.c	2014-05-29 14:19:53.089167807 -0600
a9fe34
@@ -0,0 +1,20 @@
a9fe34
+#define _GNU_SOURCE
a9fe34
+#include <string.h>
a9fe34
+#include <wchar.h>
a9fe34
+
a9fe34
+#ifndef STRTOK_R
a9fe34
+#define STRTOK_R strtok_r
a9fe34
+#define TYPE char
a9fe34
+#endif
a9fe34
+
a9fe34
+TYPE arr1[10] = {0};
a9fe34
+TYPE arr2[10] = {0};
a9fe34
+TYPE *p1 = &arr1[0];
a9fe34
+TYPE *p2 = &arr2[1];
a9fe34
+size_t count = 9;
a9fe34
+main ()
a9fe34
+{
a9fe34
+  return STRTOK_R (NULL, NULL, NULL) == 0 ;
a9fe34
+}
a9fe34
+
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/strxfrm.c b/testsuite/memstomp.null/strxfrm.c
a9fe34
--- a/testsuite/memstomp.null/strxfrm.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strxfrm.c	2014-05-29 14:06:23.335256429 -0600
a9fe34
@@ -0,0 +1,2 @@
a9fe34
+#define STRNCPY strxfrm
a9fe34
+#include "strcmp.c"
a9fe34
diff -Nrup a/testsuite/memstomp.null/strxfrm_l.c b/testsuite/memstomp.null/strxfrm_l.c
a9fe34
--- a/testsuite/memstomp.null/strxfrm_l.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/strxfrm_l.c	2014-05-29 14:07:10.004136524 -0600
a9fe34
@@ -0,0 +1,19 @@
a9fe34
+#define _GNU_SOURCE
a9fe34
+#include <string.h>
a9fe34
+#include <wchar.h>
a9fe34
+
a9fe34
+#ifndef STRCMP
a9fe34
+#define STRCMP strxfrm_l
a9fe34
+#endif
a9fe34
+
a9fe34
+
a9fe34
+char arr1[32] = "this is a test";
a9fe34
+char arr2[32] = "this is a test";
a9fe34
+char *p1 = &arr1[0];
a9fe34
+char *p2 = &arr2[1];
a9fe34
+main ()
a9fe34
+{
a9fe34
+  return STRCMP (NULL, NULL, 0, NULL);
a9fe34
+}
a9fe34
+
a9fe34
+
a9fe34
diff -Nrup a/testsuite/memstomp.null/wmemcpy.c b/testsuite/memstomp.null/wmemcpy.c
a9fe34
--- a/testsuite/memstomp.null/wmemcpy.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/wmemcpy.c	2014-05-29 12:42:18.359166205 -0600
a9fe34
@@ -0,0 +1,3 @@
a9fe34
+#define MEMCPY wmemcpy
a9fe34
+#define TYPE wchar_t
a9fe34
+#include "memcpy.c"
a9fe34
diff -Nrup a/testsuite/memstomp.null/wmempcpy.c b/testsuite/memstomp.null/wmempcpy.c
a9fe34
--- a/testsuite/memstomp.null/wmempcpy.c	1969-12-31 17:00:00.000000000 -0700
a9fe34
+++ b/testsuite/memstomp.null/wmempcpy.c	2014-05-29 12:42:18.359166205 -0600
a9fe34
@@ -0,0 +1,3 @@
a9fe34
+#define MEMCPY wmempcpy
a9fe34
+#define TYPE wchar_t
a9fe34
+#include "memcpy.c"