summaryrefslogtreecommitdiffstats
path: root/term-utils
diff options
context:
space:
mode:
authorKarel Zak2018-10-03 17:08:11 +0200
committerKarel Zak2018-10-03 17:10:44 +0200
commitc0c4feec88a5fc78c527e2cda440231101938be9 (patch)
treeddb624f89b428750dca2549f3c9c5998a66cc3fb /term-utils
parentsu: cleanup code to copy to log strings (diff)
downloadkernel-qcow2-util-linux-c0c4feec88a5fc78c527e2cda440231101938be9.tar.gz
kernel-qcow2-util-linux-c0c4feec88a5fc78c527e2cda440231101938be9.tar.xz
kernel-qcow2-util-linux-c0c4feec88a5fc78c527e2cda440231101938be9.zip
agetty: 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 'term-utils')
-rw-r--r--term-utils/agetty.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index e22600e28..97dc45bd3 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -957,7 +957,7 @@ static void update_utmp(struct options *op)
memset(&ut, 0, sizeof(ut));
if (vcline && *vcline)
/* Standard virtual console devices */
- strncpy(ut.ut_id, vcline, sizeof(ut.ut_id));
+ str2memcpy(ut.ut_id, vcline, sizeof(ut.ut_id));
else {
size_t len = strlen(line);
char * ptr;
@@ -965,14 +965,14 @@ static void update_utmp(struct options *op)
ptr = line + len - sizeof(ut.ut_id);
else
ptr = line;
- strncpy(ut.ut_id, ptr, sizeof(ut.ut_id));
+ str2memcpy(ut.ut_id, ptr, sizeof(ut.ut_id));
}
}
- strncpy(ut.ut_user, "LOGIN", sizeof(ut.ut_user));
- strncpy(ut.ut_line, line, sizeof(ut.ut_line));
+ str2memcpy(ut.ut_user, "LOGIN", sizeof(ut.ut_user));
+ str2memcpy(ut.ut_line, line, sizeof(ut.ut_line));
if (fakehost)
- strncpy(ut.ut_host, fakehost, sizeof(ut.ut_host));
+ str2memcpy(ut.ut_host, fakehost, sizeof(ut.ut_host));
time(&t);
ut.ut_tv.tv_sec = t;
ut.ut_type = LOGIN_PROCESS;