summaryrefslogtreecommitdiff
path: root/usr.bin/w/w.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-04-01 07:58:41 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-04-01 07:58:41 +0000
commitd991cf190b9b712ffeaca8c9f56812def6b605a7 (patch)
tree9db363d4883a68baf3fa3b22675f78e686d1076b /usr.bin/w/w.c
parent34c7a6818e00baed3b9a40a0be059c2c2b878b99 (diff)
Slightly better fix. This one is explicately bounded by UT_HOSTSIZE.
Diffstat (limited to 'usr.bin/w/w.c')
-rw-r--r--usr.bin/w/w.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c
index e7509e0fd55..ad8e160126b 100644
--- a/usr.bin/w/w.c
+++ b/usr.bin/w/w.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: w.c,v 1.15 1997/03/30 18:16:02 millert Exp $ */
+/* $OpenBSD: w.c,v 1.16 1997/04/01 07:58:40 millert Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@@ -300,10 +300,12 @@ main(argc, argv)
for (ep = ehead; ep != NULL; ep = ep->next) {
p = *ep->utmp.ut_host ? ep->utmp.ut_host : "-";
- if ((x = strchr(p, ':')) != NULL && x - p <= UT_HOSTSIZE)
- *x++ = '\0';
- else
- x = NULL;
+ for (x = NULL, i = 0; p[i] != '\0' && i < UT_HOSTSIZE; i++)
+ if (p[i] == ':') {
+ x = &p[i];
+ *x++ = '\0';
+ break;
+ }
if (!nflag && isdigit(*p) &&
(long)(l = inet_addr(p)) != -1 &&
(hp = gethostbyaddr((char *)&l, sizeof(l), AF_INET))) {