diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2024-04-29 10:11:12 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2024-05-02 09:08:36 +0000 |
commit | 3f59eb314103869e3f54468cf2a2b4464bd8a484 (patch) | |
tree | c7fd04dd76ff679e36a4ba29898984fc76482fe8 | |
parent | f8575d4e47587dc0153360debd3a6ec5665a57b5 (diff) | |
download | src-3f59eb314103869e3f54468cf2a2b4464bd8a484.tar.gz src-3f59eb314103869e3f54468cf2a2b4464bd8a484.zip |
libulog: Make sure ut_line, ut_user, ut_host are terminated.
MFC after: 3 days
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D45004
(cherry picked from commit c28253ecde333c9908b7160664805acc3a92e2b0)
-rw-r--r-- | lib/libulog/ulog_login.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libulog/ulog_login.c b/lib/libulog/ulog_login.c index dc08ac7d331d..adf6bdbb7489 100644 --- a/lib/libulog/ulog_login.c +++ b/lib/libulog/ulog_login.c @@ -50,7 +50,7 @@ ulog_fill(struct utmpx *utx, const char *line) utx->ut_pid = getpid(); gettimeofday(&utx->ut_tv, NULL); - strncpy(utx->ut_line, line, sizeof utx->ut_line); + strlcpy(utx->ut_line, line, sizeof utx->ut_line); SHA1_Init(&c); SHA1_Update(&c, "libulog", 7); @@ -67,9 +67,9 @@ ulog_login(const char *line, const char *user, const char *host) ulog_fill(&utx, line); utx.ut_type = USER_PROCESS; - strncpy(utx.ut_user, user, sizeof utx.ut_user); + strlcpy(utx.ut_user, user, sizeof utx.ut_user); if (host != NULL) - strncpy(utx.ut_host, host, sizeof utx.ut_host); + strlcpy(utx.ut_host, host, sizeof utx.ut_host); pututxline(&utx); } |