summaryrefslogtreecommitdiffstats
path: root/login-utils
diff options
context:
space:
mode:
authorKarel Zak2018-10-03 17:08:11 +0200
committerKarel Zak2018-10-03 17:10:13 +0200
commit7f76bc8a7557aa835667566aef9c8a2a8b18c2bb (patch)
treef7c0b164747dad45c42fe1ac20770b1d7fec2bad /login-utils
parentlogin: cleanup code to copy to log strings (diff)
downloadkernel-qcow2-util-linux-7f76bc8a7557aa835667566aef9c8a2a8b18c2bb.tar.gz
kernel-qcow2-util-linux-7f76bc8a7557aa835667566aef9c8a2a8b18c2bb.tar.xz
kernel-qcow2-util-linux-7f76bc8a7557aa835667566aef9c8a2a8b18c2bb.zip
su: cleanup code to copy to log strings
man utmp: String fields are terminated by a null byte ('\0') if they are shorter than the size of the field. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils')
-rw-r--r--login-utils/su-common.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/login-utils/su-common.c b/login-utils/su-common.c
index 1b1370922..e0604e246 100644
--- a/login-utils/su-common.c
+++ b/login-utils/su-common.c
@@ -609,14 +609,14 @@ static void log_btmp(struct su_context *su)
DBG(LOG, ul_debug("btmp logging"));
memset(&ut, 0, sizeof(ut));
- strncpy(ut.ut_user,
+ str2memcpy(ut.ut_user,
su->pwd && su->pwd->pw_name ? su->pwd->pw_name : "(unknown)",
sizeof(ut.ut_user));
if (su->tty_number)
- xstrncpy(ut.ut_id, su->tty_number, sizeof(ut.ut_id));
+ str2memcpy(ut.ut_id, su->tty_number, sizeof(ut.ut_id));
if (su->tty_name)
- xstrncpy(ut.ut_line, su->tty_name, sizeof(ut.ut_line));
+ str2memcpy(ut.ut_line, su->tty_name, sizeof(ut.ut_line));
gettimeofday(&tv, NULL);
ut.ut_tv.tv_sec = tv.tv_sec;