]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
last: fix wtmp user name buffer overflow [asan]
authorSami Kerola <kerolasa@iki.fi>
Sun, 13 Jan 2019 19:48:59 +0000 (19:48 +0000)
committerKarel Zak <kzak@redhat.com>
Tue, 2 Apr 2019 10:12:28 +0000 (12:12 +0200)
Ensure utmp user name field is null terminated.  Without that getpwnam() can
buffer overflow, when wtmp file is malformed.

Addresses: https://github.com/karelzak/util-linux/issues/715
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
login-utils/last.c

index 6b25efd4c6932cbc96080bb971e27121c1099329..be744b079198ecf11ba05eed990c5f942bca18c0 100644 (file)
@@ -600,6 +600,7 @@ static int is_phantom(const struct last_control *ctl, struct utmpx *ut)
 
        if (ut->ut_tv.tv_sec < ctl->boot_time.tv_sec)
                return 1;
+       ut->ut_user[__UT_NAMESIZE - 1] = '\0';
        pw = getpwnam(ut->ut_user);
        if (!pw)
                return 1;