summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>1997-03-30 18:16:02 +0000
committermillert <millert@openbsd.org>1997-03-30 18:16:02 +0000
commitd3262dce15f6973928d58d046d6f540fe57286c4 (patch)
treea396a0bdbf6ff65980a773a74df7146f6bd99a0a
parentMake named.boot and news spool optional. (diff)
downloadwireguard-openbsd-d3262dce15f6973928d58d046d6f540fe57286c4.tar.xz
wireguard-openbsd-d3262dce15f6973928d58d046d6f540fe57286c4.zip
NetBSD PR #3399: Avoid overflowing in ut_host into ut_time (bounds check). Fix from Tatoku Ogaito
-rw-r--r--usr.bin/w/w.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c
index 380f19b3534..e7509e0fd55 100644
--- a/usr.bin/w/w.c
+++ b/usr.bin/w/w.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: w.c,v 1.14 1997/03/25 21:24:12 deraadt Exp $ */
+/* $OpenBSD: w.c,v 1.15 1997/03/30 18:16:02 millert Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@@ -300,8 +300,10 @@ 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)
+ if ((x = strchr(p, ':')) != NULL && x - p <= UT_HOSTSIZE)
*x++ = '\0';
+ else
+ x = NULL;
if (!nflag && isdigit(*p) &&
(long)(l = inet_addr(p)) != -1 &&
(hp = gethostbyaddr((char *)&l, sizeof(l), AF_INET))) {