Commit d9b72610 authored by Damien George's avatar Damien George

lib/libc: Fix string0's implementation of strncpy.

Fixing 98e58343, the semantics of strncpy
require that the remainder of dst be filled with null bytes.
Signed-off-by: default avatarDamien George <damien@micropython.org>
parent 27767aaf
......@@ -178,8 +178,10 @@ char *strncpy(char *s1, const char *s2, size_t n) {
while (n > 0) {
n--;
if ((*dst++ = *src++) == '\0') {
/* If we get here, we found a null character at the end of s2 */
*dst = '\0';
/* If we get here, we found a null character at the end
of s2, so use memset to put null bytes at the end of
s1. */
memset(dst, '\0', n);
break;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment