diff options
author | Alejandro Colomar <alx@kernel.org> | 2023-11-16 00:08:47 +0100 |
---|---|---|
committer | Alejandro Colomar <alx@kernel.org> | 2023-11-16 15:26:45 +0100 |
commit | 6907d3c960a0aa07123cea50dc1da2c2e735def1 (patch) | |
tree | 7fc8924dbd39d4b76c4dfd9dec753b0c8219d0c6 | |
parent | 8d62cac5ea3424329f1734ae32363cdf90b0877d (diff) |
lib/log.c: Replace strncpy(3) call by STRTCPY()
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>
-rw-r--r-- | lib/log.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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 |