[hackers] [scc] [libc] Fix strncpy || Quentin Rameau
commit 6cdd955f1d50996aa6b411756910e813f591e2f0
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Fri Feb 17 00:21:50 2017 +0100
Commit: Quentin Rameau <quinq_AT_fifth.space>
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
_AT_@ -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;
Received on Fri Feb 17 2017 - 11:01:40 CET
This archive was generated by hypermail 2.3.0
: Fri Feb 17 2017 - 11:12:23 CET