linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PATCH: fix strncpy on generic user platforms
@ 2003-07-27 20:23 Alan Cox
  0 siblings, 0 replies; only message in thread
From: Alan Cox @ 2003-07-27 20:23 UTC (permalink / raw)
  To: linux-kernel, torvalds

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-07-28  0:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-27 20:23 PATCH: fix strncpy on generic user platforms Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).