The definition of strncpy() is that empty space should be zero-filled, the patch adds the zero filling (I didn’t know this, see e.g. the POSIX spec here: http://pubs.opengroup.org/onlinepubs/7908799/xsh/strncpy.html). From Lorenz Meier.
This commit is contained in:
parent
a61802640f
commit
639641dc04
|
@ -55,7 +55,8 @@ char *strncpy(FAR char *dest, FAR const char *src, size_t n)
|
||||||
char *ret = dest; /* Value to be returned */
|
char *ret = dest; /* Value to be returned */
|
||||||
char *end = dest + n; /* End of dest buffer + 1 byte */
|
char *end = dest + n; /* End of dest buffer + 1 byte */
|
||||||
|
|
||||||
while (dest != end && (*dest++ = *src++) != '\0');
|
while ((*dest++ = *src++) != '\0' && dest != end);
|
||||||
|
while (dest != end) *dest++ = '\0';
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue