commit 6cdd955f1d50996aa6b411756910e813f591e2f0
Author: Quentin Rameau <[email protected]>
AuthorDate: Fri Feb 17 00:21:50 2017 +0100
Commit: Quentin Rameau <[email protected]>
CommitDate: Fri Feb 17 11:00:33 2017 +0100
[libc] Fix strncpy
Don't forget n is unsigned.
diff --git a/libc/src/strncpy.c b/libc/src/strncpy.c
index af3b41b..a1a1456 100644
--- a/libc/src/strncpy.c
+++ b/libc/src/strncpy.c
@@ -7,8 +7,8 @@ strncpy(char *dst, const char *src, size_t n)
{
char *ret = dst;
- while (n-- > 0 && (*dst++ = *src++))
- /* nothing */;
+ for (; n > 0 && *src; --n)
+ *dst++ = *src++;
while (n-- > 0)
*dst++ = '\0';
return ret;