Subject: bin/28751: /usr/bin/w dynamic sizing of FROM column problems
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <eravin@panix.com>
List: netbsd-bugs
Date: 12/22/2004 08:21:00
>Number:         28751
>Category:       bin
>Synopsis:       /usr/bin/w dynamic sizing of FROM column problems
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 22 08:21:00 +0000 2004
>Originator:     Ed Ravin
>Release:        2.0
>Organization:
Panix
>Environment:
NetBSD panix3.panix.com 2.0 NetBSD 2.0 (PANIX-USER) #0: Fri Dec 17 22:40:30 EST 2004  root@trinity.nyc.access.net:/devel/netbsd/2.0/src/sys/arch/i386/compile/PANIX-USER i386

>Description:
we have three identical machines - on one of them, /usr/bin/w output is oddly formatted, with each line 88 characters long on an 80 column terminal.  Note the user logged in from a very long rcn.com hostname - I suspect something is going on with w's attempts to dynamically size the output based on the size of the hostname in utmpx.  I don't fully grok the code in w.c, but it doesn't seem to check for things like a 256 character hostname.

Also, unlike /usr/bin/last, there are no command-line options to adjust how much hostname output you want.

 1:40PM  up 3 days, 13:21, 123 users, load averages: 0.83, 1.78, 3.01
USER    TTY FROM                                                   LOGIN@  IDLE WHAT
drewc    p0 160.79.63.99                                           9:51AM  1:07 -tcsh 
dn       p1 66-108-85-142.nyc.rr.com                               1:08PM     0 /usr/lo 
kerausch p2 128.231.233.251                                        8:42AM    34 -bash 
mikhail  p3 whasup.com                                             8:54AM    59 -zsh 
ahall    p4 204.110.136.3                                          7:39AM    27 emacs - 
mappel   p5 207-237-134-44.c3-0.80w-ubr15.nyr-80w.ny.cable.rcn.co Sat12AM    15 pine -i 

>How-To-Repeat:
Dunno.  Here are the three rcn.com hostnames that might be provoking the bug:

207-237-134-44.c3-0.80w-ubr15.nyr-80w.ny.cable.rcn.com
208-59-173-123.c3-0.bth-ubr7.lnh-bth.md.cable.rcn.com
208-58-69-63.c3-0.161-ubr2.lnh-161.md.cable.rcn.com

I note that the 2nd one above is exactly the size of the FROM field
output by w.  But when I tried faking that hostname on a test box in
/etc/hosts, I couldn't reproduce the abberant behavior with the 88-column output.
>Fix: