From b33d0943b18b04ed3f1887b6704f11cb86eedb83 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 14 Aug 2003 10:24:05 -0700 Subject: [PATCH] Fix strncpy off-by-one error From: Yoshinori Sato It writes one too many zeroes when nulling out the destination. --- lib/string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/string.c') diff --git a/lib/string.c b/lib/string.c index d50185536bf3..05dfb7ff5fd9 100644 --- a/lib/string.c +++ b/lib/string.c @@ -89,7 +89,7 @@ char * strncpy(char * dest,const char *src,size_t count) while (count && (*dest++ = *src++) != '\0') count--; - while (count) { + while (count > 1) { *dest++ = 0; count--; } -- cgit v1.2.3