From 92172c87b43ffbd1a0b786c3db286be124fcc5b8 Mon Sep 17 00:00:00 2001 From: David Greenman Date: Tue, 16 May 1995 11:29:41 +0000 Subject: [PATCH] If an ut_host field in an utmp entry contains a ':' (e.g. for an xterm session) w doesn't handle the non-'\0' terminated char arrays in struct utmp properly. Submitted by: jarle@idt.unit.no --- usr.bin/w/w.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index 0a31930ca45..ea5d2ca2bbc 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -307,7 +307,8 @@ main(argc, argv) p = hp->h_name; } if (x) { - (void)snprintf(buf, sizeof(buf), "%s:%s", p, x); + (void)snprintf(buf, sizeof(buf), "%s:%.*s", p, + ep->utmp.ut_host + UT_HOSTSIZE - x, x); p = buf; } (void)printf("%-*.*s %-2.2s %-*.*s ",