The branch main has been updated by swills (ports committer):

URL: 
https://cgit.FreeBSD.org/src/commit/?id=db11c57a6cf3053fb09185975cfbe3729f2fbe44

commit db11c57a6cf3053fb09185975cfbe3729f2fbe44
Author:     Steve Wills <[email protected]>
AuthorDate: 2022-03-12 16:48:24 +0000
Commit:     Steve Wills <[email protected]>
CommitDate: 2022-03-12 16:49:49 +0000

    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);
        }
 }
 

Reply via email to