PATCH: fix strncpy on generic user platforms

From: Alan Cox (alan@lxorguk.ukuu.org.uk)
Date: Sun Jul 27 2003 - 15:23:49 EST


diff -u --new-file --recursive --exclude-from /usr/src/exclude linux-2.6.0-test2/lib/string.c linux-2.6.0-test2-ac1/lib/string.c
--- linux-2.6.0-test2/lib/string.c 2003-07-10 21:13:38.000000000 +0100
+++ linux-2.6.0-test2-ac1/lib/string.c 2003-07-17 17:46:40.000000000 +0100
@@ -80,8 +80,7 @@
  * @src: Where to copy the string from
  * @count: The maximum number of bytes to copy
  *
- * Note that unlike userspace strncpy, this does not %NUL-pad the buffer.
- * However, the result is not %NUL-terminated if the source exceeds
+ * The result is not %NUL-terminated if the source exceeds
  * @count bytes.
  */
 char * strncpy(char * dest,const char *src,size_t count)
@@ -90,7 +89,8 @@
 
         while (count-- && (*dest++ = *src++) != '\0')
                 /* nothing */;
-
+ while (count-- > 0)
+ *dest++ = 0;
         return tmp;
 }
 #endif
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Jul 31 2003 - 22:00:33 EST