ref: 1ee8ce7474148da51b4b0bfc8e1e1a87c00ed04e
parent: 79fa0e66f2a16cbc6ba50641794e69f44fc6d2ac
author: Quentin Rameau <quinq@fifth.space>
date: Thu Feb 16 19:21:50 EST 2017
[libc] Fix strncpy Don't forget n is unsigned.
--- a/libc/src/strncpy.c
+++ b/libc/src/strncpy.c
@@ -7,8 +7,8 @@
{
char *ret = dst;
- while (n-- > 0 && (*dst++ = *src++))
- /* nothing */;
+ for (; n > 0 && *src; --n)
+ *dst++ = *src++;
while (n-- > 0)
*dst++ = '\0';
return ret;