mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
who: fix only-theoretical overflow
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.
This commit is contained in:
1 parent
779f34e180
commit
9cbda6e1f8
1 file changed
+2
-2
+2
-2
@@ -781,8 +781,8 @@ write_error (void)
|
||||
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;
|
||||
|
||||
Reference in new issue
Block a user