]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
last: make sure domain is zero terminated
authorKarel Zak <kzak@redhat.com>
Wed, 3 Oct 2018 15:06:33 +0000 (17:06 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 3 Oct 2018 15:06:33 +0000 (17:06 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/last.c

index 59dfdb2f5e77ce7a383ae08efd75799ee7c25d4d..6b25efd4c6932cbc96080bb971e27121c1099329 100644 (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) {