Change stzncpy’s implementation to match its comment, in the case
where SRC + LEN would overflow. This case never happens in coreutils.
* src/system.h (stzncpy): Work even if SRC + LEN would overflow.
static inline char *
stzncpy (char *restrict dest, char const *restrict src, size_t len)
{
- char const *src_end = src + len;
- while (src < src_end && *src)
+ size_t i;
+ for (i = 0; i < len && *src; i++)
*dest++ = *src++;
*dest = 0;
return dest;