]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/failure.c: Replace strncpy(3) call by STRTCPY()
authorAlejandro Colomar <alx@kernel.org>
Wed, 15 Nov 2023 22:58:23 +0000 (23:58 +0100)
committerSerge Hallyn <serge@hallyn.com>
Sun, 26 Nov 2023 12:48:18 +0000 (06:48 -0600)
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 <mattlloydhouse@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/failure.c

index 1d2d910ab2611c1082cd5b7df0d8c90b166f1dbf..c4a434ffb1c7a89340e0fe7ab3aa3241e15da875 100644 (file)
@@ -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);
 
        /*