[libc] fix strncpy to zero out remaining space in the target

This commit is contained in:
Travis Geiselbrecht
2018-12-16 17:23:56 -08:00
parent 08a4ee17f0
commit e608867d71

View File

@@ -32,8 +32,11 @@ strncpy(char *dest, char const *src, size_t count)
{
char *tmp = dest;
while (count-- && (*dest++ = *src++) != '\0')
size_t i;
for (i = 0; i < count && (*dest++ = *src++) != '\0'; i++)
;
for (; i < count; i++)
*dest++ = '\0';
return tmp;
}