Copy all chars of UTMP fields: id, line, and user

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2016-08-09 20:35:44 +02:00
1 parent dbbe6b31b8
commit b01fae03ec
1 file changed
+5 -5
+5 -5
View File
@@ -46,14 +46,14 @@ int utmp_set(int type, int pid, char *line, char *id, char *user)
} }
memset(&ut, 0, sizeof(ut)); memset(&ut, 0, sizeof(ut));
ut.ut_type = type; ut.ut_type = type;
ut.ut_pid = pid; ut.ut_pid = pid;
if (user) if (user)
strlcpy(ut.ut_user, user, sizeof(ut.ut_user)); strncpy(ut.ut_user, user, sizeof(ut.ut_user));
if (line) if (line)
strlcpy(ut.ut_line, line, sizeof(ut.ut_line)); strncpy(ut.ut_line, line, sizeof(ut.ut_line));
if (id) if (id)
strlcpy(ut.ut_id, id, sizeof(ut.ut_id)); strncpy(ut.ut_id, id, sizeof(ut.ut_id));
if (!uname(&uts)) if (!uname(&uts))
strncpy(ut.ut_host, uts.release, sizeof(ut.ut_host)); strncpy(ut.ut_host, uts.release, sizeof(ut.ut_host));
ut.ut_tv.tv_sec = time(NULL); ut.ut_tv.tv_sec = time(NULL);