string/test-memcpy error reporting
authorAlan Modra <amodra@gmail.com>
Sat, 17 Aug 2013 09:07:58 +0000 (18:37 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 4 Oct 2013 01:12:02 +0000 (10:42 +0930)
http://sourceware.org/ml/libc-alpha/2013-08/msg00094.html

Using plain %s here runs the risk of segfaulting when displaying the
string.  src and dst aren't zero terminated strings.

* string/test-memcpy.c (do_one_test): When reporting errors, print
string address and don't overrun end of string.

ChangeLog
string/test-memcpy.c

index 42607ea..a1c6f5c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2013-10-04  Alan Modra  <amodra@gmail.com>
 
+       * string/test-memcpy.c (do_one_test): When reporting errors, print
+       string address and don't overrun end of string.
+
+2013-10-04  Alan Modra  <amodra@gmail.com>
+
        * sysdeps/powerpc/powerpc64/power7/memchr.S: Replace rlwimi with
        insrdi.  Make better use of reg selection to speed exit slightly.
        Schedule entry path a little better.  Remove useless "are we done"
index d121ef0..b7ebe5f 100644 (file)
@@ -63,8 +63,8 @@ do_one_test (impl_t *impl, char *dst, const char *src,
 
   if (memcmp (dst, src, len) != 0)
     {
-      error (0, 0, "Wrong result in function %s dst \"%s\" src \"%s\"",
-            impl->name, dst, src);
+      error (0, 0, "Wrong result in function %s dst %p \"%.*s\" src %p \"%.*s\" len %zu",
+            impl->name, dst, (int) len, dst, src, (int) len, src, len);
       ret = 1;
       return;
     }