From 384aa0c6964cf9f105c817090d97e648700f4539 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 5 Jul 2011 14:12:48 +0000 Subject: Only print entries for which ut_host points to a character device. Now that we use utmpx, we more often have entries for which the ut_line is left blank. To prevent us from returning struct stat for "/dev/", check that the resulting stat structure belongs to a character device. --- usr.bin/w/w.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr.bin/w/w.c') diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index 43f1926..0331287 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -497,7 +497,7 @@ ttystat(char *line) char ttybuf[MAXPATHLEN]; (void)snprintf(ttybuf, sizeof(ttybuf), "%s%s", _PATH_DEV, line); - if (stat(ttybuf, &sb) == 0) { + if (stat(ttybuf, &sb) == 0 && S_ISCHR(sb.st_mode)) { return (&sb); } else return (NULL); -- cgit v1.1