While copying 'dst len' bytes in strncpy is normally risky
as the dst may not be NULL-terminated, this function ensures
that the last byte of 'dst' is NULL.
Therefore, this change is mostly made to silence GCC.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
/* Version of strncpy that ensures dest (size bytes) is null-terminated. */
static char* strncpy0(char* dest, const char* src, size_t size)
{
- strncpy(dest, src, size);
+ strncpy(dest, src, size - 1);
dest[size - 1] = '\0';
return dest;
}