summaryrefslogtreecommitdiffstats
path: root/usr.bin/w/w.c
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2011-07-05 14:12:48 +0000
committered <ed@FreeBSD.org>2011-07-05 14:12:48 +0000
commit384aa0c6964cf9f105c817090d97e648700f4539 (patch)
treed1048751916250fac781f5dbca277d4340e5180a /usr.bin/w/w.c
parent6abbb93d5fb70390974d5b0bb73e75616bd9c39a (diff)
downloadFreeBSD-src-384aa0c6964cf9f105c817090d97e648700f4539.zip
FreeBSD-src-384aa0c6964cf9f105c817090d97e648700f4539.tar.gz
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.
Diffstat (limited to 'usr.bin/w/w.c')
-rw-r--r--usr.bin/w/w.c2
1 files changed, 1 insertions, 1 deletions
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);
OpenPOWER on IntegriCloud