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
This commit is contained in:
David Greenman 1995-05-16 11:29:41 +00:00
parent d5531570b4
commit 92172c87b4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=8555

View File

@ -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 ",