Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 May 2024 09:08:28 GMT
From:      Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= <des@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 2bdfc2988986 - stable/14 - libulog: Make sure ut_line, ut_user, ut_host are terminated.
Message-ID:  <202405020908.44298SDm040189@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=2bdfc2988986461bac0c28fb6fdc4ee99e421c6c

commit 2bdfc2988986461bac0c28fb6fdc4ee99e421c6c
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2024-04-29 10:11:12 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2024-05-02 09:08:17 +0000

    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)
---
 lib/libulog/ulog_login.c | 6 +++---
 1 file 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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202405020908.44298SDm040189>