summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2015-10-11 23:29:56 +0000
committerderaadt <deraadt@openbsd.org>2015-10-11 23:29:56 +0000
commitd8f7535e34422f6cfeee72b853e02c8c7db24088 (patch)
treea18b3b1ebf42b14ff09c261aab2db380a8ccb269
parentpledge_ioctl_check() will do the killing if neccessary; if it returns, (diff)
downloadwireguard-openbsd-d8f7535e34422f6cfeee72b853e02c8c7db24088.tar.xz
wireguard-openbsd-d8f7535e34422f6cfeee72b853e02c8c7db24088.zip
fix regression: ttyname() failure not handled right
-rw-r--r--usr.bin/who/who.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/who/who.c b/usr.bin/who/who.c
index da750dc0ef5..62cfb034510 100644
--- a/usr.bin/who/who.c
+++ b/usr.bin/who/who.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: who.c,v 1.24 2015/10/10 22:06:41 deraadt Exp $ */
+/* $OpenBSD: who.c,v 1.25 2015/10/11 23:29:56 deraadt Exp $ */
/* $NetBSD: who.c,v 1.4 1994/12/07 04:28:49 jtc Exp $ */
/*
@@ -77,10 +77,11 @@ main(int argc, char *argv[])
if (pledge("stdio rpath getpw tty", NULL) == -1)
err(1, "pledge");
- mytty = ttyname(0);
- /* strip any directory component */
- if ((t = strrchr(mytty, '/')))
- mytty = t + 1;
+ if (mytty = ttyname(0)) {
+ /* strip any directory component */
+ if ((t = strrchr(mytty, '/')))
+ mytty = t + 1;
+ }
only_current_term = show_term = show_idle = show_labels = 0;
show_quick = 0;