summaryrefslogtreecommitdiffstats
path: root/usr.bin/w/w.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1999-04-22 23:40:56 +0000
committerache <ache@FreeBSD.org>1999-04-22 23:40:56 +0000
commitb7c354e27c05bf11e63e310dfed8029ecfe065d8 (patch)
tree10ed4f1f442c56b9f09caa96103d142763ced9d5 /usr.bin/w/w.c
parent43e60106b0c55037543e4c273d5346edb72e03b9 (diff)
downloadFreeBSD-src-b7c354e27c05bf11e63e310dfed8029ecfe065d8.zip
FreeBSD-src-b7c354e27c05bf11e63e310dfed8029ecfe065d8.tar.gz
fix -n with 16-chars hostnames, modified patch from PR
PR: 11286 Submitted by: Hans Huebner <hans@chaosradio.berlin.ccc.de>
Diffstat (limited to 'usr.bin/w/w.c')
-rw-r--r--usr.bin/w/w.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c
index 26a6040..9e1fe70 100644
--- a/usr.bin/w/w.c
+++ b/usr.bin/w/w.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)w.c 8.4 (Berkeley) 4/16/94";
#endif
static const char rcsid[] =
- "$Id: w.c,v 1.32 1999/01/10 15:28:37 peter Exp $";
+ "$Id: w.c,v 1.33 1999/03/31 21:01:39 brian Exp $";
#endif /* not lint */
/*
@@ -335,7 +335,11 @@ main(argc, argv)
}
for (ep = ehead; ep != NULL; ep = ep->next) {
- p = *ep->utmp.ut_host ? ep->utmp.ut_host : "-";
+ char host_buf[UT_HOSTSIZE + 1];
+
+ host_buf[UT_HOSTSIZE] = '\0';
+ strncpy(host_buf, ep->utmp.ut_host, UT_HOSTSIZE);
+ p = *host_buf ? host_buf : "-";
if ((x = strchr(p, ':')) != NULL)
*x++ = '\0';
if (!nflag && isdigit(*p) &&
@@ -362,8 +366,7 @@ main(argc, argv)
}
}
if (x) {
- (void)snprintf(buf, sizeof(buf), "%s:%.*s", p,
- ep->utmp.ut_host + UT_HOSTSIZE - x, x);
+ (void)snprintf(buf, sizeof(buf), "%s:%s", p, x);
p = buf;
}
if (dflag) {
OpenPOWER on IntegriCloud