last: use domain string more carefully
Use xstrcpy() to explicitly terminate the domain string. Reported-by: Tobias Stoeckmann <tobias@stoeckmann.org> Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
b0f97de5a4
commit
bd2aece45e
|
@ -505,10 +505,12 @@ static int list(const struct last_control *ctl, struct utmpx *p, time_t logout_t
|
|||
if (ctl->usedns || ctl->useip)
|
||||
r = dns_lookup(domain, sizeof(domain), ctl->useip, p->ut_addr_v6);
|
||||
if (r < 0) {
|
||||
len = sizeof(p->ut_host);
|
||||
if (len >= (int)sizeof(domain)) len = sizeof(domain) - 1;
|
||||
domain[0] = 0;
|
||||
strncat(domain, p->ut_host, len);
|
||||
size_t sz = sizeof(p->ut_host);
|
||||
|
||||
if (sz > sizeof(domain))
|
||||
sz = sizeof(domain);
|
||||
|
||||
xstrncpy(domain, p->ut_host, sz);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue