last: make sure domain is zero terminated

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2018-10-03 17:06:33 +02:00
parent 0b6bb91adf
commit 22fbfdb8f5
1 changed files with 2 additions and 9 deletions

View File

@ -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) {