From: Alejandro Colomar Date: Wed, 15 Nov 2023 22:58:23 +0000 (+0100) Subject: lib/failure.c: Replace strncpy(3) call by STRTCPY() X-Git-Tag: 4.15.0-rc1~124 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09957c6d273a7b4c1e85f623ed41633f343be88a;p=thirdparty%2Fshadow.git lib/failure.c: Replace strncpy(3) call by STRTCPY() This call was way too clever. It relied on the last byte of fail_line being 0 due to it being in a static structure and never writing to it. Write an explicit terminating null byte, by using STRTCPY(). Cc: Matthew House Signed-off-by: Alejandro Colomar --- diff --git a/lib/failure.c b/lib/failure.c index 1d2d910ab..c4a434ffb 100644 --- a/lib/failure.c +++ b/lib/failure.c @@ -19,6 +19,7 @@ #include "failure.h" #include "memzero.h" #include "prototypes.h" +#include "strtcpy.h" #define YEAR (365L*DAY) @@ -78,7 +79,7 @@ void failure (uid_t uid, const char *tty, struct faillog *fl) fl->fail_cnt++; } - strncpy (fl->fail_line, tty, sizeof (fl->fail_line) - 1); + STRTCPY(fl->fail_line, tty); (void) time (&fl->fail_time); /*