]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/log.c: Replace strncpy(3) call by STRTCPY()
authorAlejandro Colomar <alx@kernel.org>
Wed, 15 Nov 2023 23:08:47 +0000 (00:08 +0100)
committerSerge Hallyn <serge@hallyn.com>
Sun, 26 Nov 2023 12:48:18 +0000 (06:48 -0600)
This call was too clever.  It relied on the last byte of ll_line
being 0 due to a previous memzero() and not writing to it later.
Write an explicit terminating null byte, by using STRTCPY().

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/log.c

index 8b3e564e5c3e0e2b2d350797bbf013864cdd13b0..9457b1cd1ed6cbed1df4aff71b89091f807d9312 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -19,6 +19,8 @@
 #include <lastlog.h>
 #include "memzero.h"
 #include "prototypes.h"
+#include "strtcpy.h"
+
 
 /*
  * dolastlog - create lastlog entry
@@ -78,7 +80,7 @@ void dolastlog (
        ll_time = newlog.ll_time;
        (void) time (&ll_time);
        newlog.ll_time = ll_time;
-       strncpy (newlog.ll_line, line, sizeof (newlog.ll_line) - 1);
+       STRTCPY(newlog.ll_line, line);
 #if HAVE_LL_HOST
        strncpy (newlog.ll_host, host, sizeof (newlog.ll_host) - 1);
 #endif