From 09957c6d273a7b4c1e85f623ed41633f343be88a Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Wed, 15 Nov 2023 23:58:23 +0100 Subject: [PATCH] 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 --- lib/failure.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/failure.c b/lib/failure.c index 1d2d910a..c4a434ff 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); /*