avoid garbage characters on long host names (from cgd)
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Fri, 1 Jul 1994 01:42:29 +0000 (17:42 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Fri, 1 Jul 1994 01:42:29 +0000 (17:42 -0800)
SCCS-vsn: usr.bin/w/w.c 8.5

usr/src/usr.bin/w/w.c

index bea90c6..5b54b8a 100644 (file)
@@ -12,7 +12,7 @@ static char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)w.c        8.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)w.c        8.5 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -281,7 +281,8 @@ main(argc, argv)
                        p = hp->h_name;
                }
                if (x) {
                        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 ",
                        p = buf;
                }
                (void)printf("%-*.*s %-2.2s %-*.*s ",