about summary refs log tree commit diff
path: root/string/stratcliff.c
diff options
context:
space:
mode:
Diffstat (limited to 'string/stratcliff.c')
-rw-r--r--string/stratcliff.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/string/stratcliff.c b/string/stratcliff.c
index f25ae0ca79..9b0e4211a6 100644
--- a/string/stratcliff.c
+++ b/string/stratcliff.c
@@ -1,5 +1,5 @@
 /* Test for string function add boundaries of usable memory.
-   Copyright (C) 1996, 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1996,1997,1999,2000,2001,2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -192,7 +192,25 @@ main (int argc, char *argv[])
 	    }
         }
 
-      /* strncpy test */
+      /* strncpy tests */
+      adr[size-1] = 'T';
+      for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
+	{
+	  size_t len;
+
+	  for (len = 0; len < size - outer; ++len)
+	    {
+	      if (strncpy (dest, &adr[outer], len) != dest
+		  || memcmp (dest, &adr[outer], len) != 0)
+		{
+		  printf ("outer strncpy flunked for outer = %d, len = %Zd\n",
+			  outer, len);
+		  result = 1;
+		}
+	    }
+        }
+      adr[size-1] = '\0';
+
       for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
         {
           for (inner = MAX (outer, size - 64); inner < size; ++inner)
@@ -213,6 +231,16 @@ main (int argc, char *argv[])
 			      outer, inner, len);
 		      result = 1;
 		    }
+		  if (strncpy (dest + 1, &adr[outer], len) != dest + 1
+		      || memcmp (dest + 1, &adr[outer],
+				 MIN (inner - outer, len)) != 0
+		      || (inner - outer < len
+			  && strlen (dest + 1) != (inner - outer)))
+		    {
+		      printf ("strncpy+1 flunked for outer = %d, inner = %d, len = %Zd\n",
+			      outer, inner, len);
+		      result = 1;
+		    }
 		}
 
 	      adr[inner] = 'T';