diff options
author | Karel Zak | 2018-10-03 17:06:33 +0200 |
---|---|---|
committer | Karel Zak | 2018-10-03 17:06:33 +0200 |
commit | 22fbfdb8f5958586116074e712fd81f4cacd206c (patch) | |
tree | 779c943dc92d9e54f9506707fd1cc283b5bff613 /login-utils/last.c | |
parent | wall: make sure line is zero terminated (diff) | |
download | kernel-qcow2-util-linux-22fbfdb8f5958586116074e712fd81f4cacd206c.tar.gz kernel-qcow2-util-linux-22fbfdb8f5958586116074e712fd81f4cacd206c.tar.xz kernel-qcow2-util-linux-22fbfdb8f5958586116074e712fd81f4cacd206c.zip |
last: make sure domain is zero terminated
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils/last.c')
-rw-r--r-- | login-utils/last.c | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/login-utils/last.c b/login-utils/last.c index 59dfdb2f5..6b25efd4c 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -508,15 +508,8 @@ static int list(const struct last_control *ctl, struct utmpx *p, time_t logout_t r = -1; if (ctl->usedns || ctl->useip) r = dns_lookup(domain, sizeof(domain), ctl->useip, (int32_t*)p->ut_addr_v6); - if (r < 0) { - size_t sz = sizeof(p->ut_host); - - if (sz > sizeof(domain)) - sz = sizeof(domain); - - xstrncpy(domain, p->ut_host, sz); - } - + if (r < 0) + mem2strcpy(domain, p->ut_host, sizeof(p->ut_host), sizeof(domain)); if (ctl->showhost) { if (!ctl->altlist) { |