From db11c57a6cf3053fb09185975cfbe3729f2fbe44 Mon Sep 17 00:00:00 2001 From: Steve Wills Date: Sat, 12 Mar 2022 11:48:24 -0500 Subject: [PATCH] usr.bin/who.c: Fix boot time checking The boot time entry doesn't have a tty specified, so don't check it. While here, make ttystat handle that case. Approved by: kevans (src) Differential Revision: https://reviews.freebsd.org/D34524 --- usr.bin/who/who.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.bin/who/who.c b/usr.bin/who/who.c index 6ad4f18c3b78..add2fb27a27a 100644 --- a/usr.bin/who/who.c +++ b/usr.bin/who/who.c @@ -216,6 +216,8 @@ ttystat(char *line) struct stat sb; char ttybuf[MAXPATHLEN]; + if (line == NULL) + return (0); (void)snprintf(ttybuf, sizeof(ttybuf), "%s%s", _PATH_DEV, line); if (stat(ttybuf, &sb) == 0) { return (0); @@ -229,10 +231,11 @@ process_utmp(void) struct utmpx *utx; while ((utx = getutxent()) != NULL) { - if (((aflag || !bflag) && utx->ut_type == USER_PROCESS) || - (bflag && utx->ut_type == BOOT_TIME)) + if ((aflag || !bflag) && utx->ut_type == USER_PROCESS) { if (ttystat(utx->ut_line) == 0) row(utx); + } else if (bflag && utx->ut_type == BOOT_TIME) + row(utx); } }