Date: Tue, 25 Dec 2007 18:49:15 GMT From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/119014: [patch] IPv6 addresses cause sockstat(1) to run columns together Message-ID: <200712251849.lBPInF76005918@happy-idiot-talk.infracaninophile.co.uk> Resent-Message-ID: <200712251850.lBPIo2Bn096800@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 119014 >Category: bin >Synopsis: [patch] IPv6 addresses cause sockstat(1) to run columns together >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Dec 25 18:50:02 UTC 2007 >Closed-Date: >Last-Modified: >Originator: Matthew Seaman >Release: FreeBSD 7.0-PRERELEASE i386 >Organization: Infracaninophile >Environment: System: FreeBSD happy-idiot-talk.infracaninophile.co.uk 7.0-PRERELEASE FreeBSD 7.0-PRERELEASE #19: Sun Dec 23 00:41:05 GMT 2007 root@happy-idiot-talk.infracaninophile.co.uk:/usr/obj/usr/src/sys/HAPPY-IDIOT-TALK i386 >Description: sockstat(1) begins the 'FOREIGN ADDRESS' column at 58 characters from the start of the line. Where the 'LOCAL ADDRESS' column is wider than this allows for, as is commonly encountered with IPv6 addresses, this leads to the 'LOCAL ADDRESS' and 'FOREIGN ADDRESS' columns being run into each other -- like so: % /usr/bin/sockstat -6 | grep ssh matthew ssh 5560 3 tcp6 2001:8b0:151:1:240:5ff:fea5:8db7:604182001:8b0:151:1:20e:35ff:fec2:d38e:22 root sshd 2244 3 tcp6 2001:8b0:151:1:240:5ff:fea5:8db7:22*:* root sshd 2244 5 tcp6 ::1:22 *:* The patch below enforces at least one space between the columns: % /usr/obj/usr/src/usr.bin/sockstat/sockstat -6 | grep ssh matthew ssh 5560 3 tcp6 2001:8b0:151:1:240:5ff:fea5:8db7:60418 2001:8b0:151:1:20e:35ff:fec2:d38e:22 root sshd 2244 3 tcp6 2001:8b0:151:1:240:5ff:fea5:8db7:22 *:* root sshd 2244 5 tcp6 ::1:22 *:* Alternatively, as the maximum width of an IPv6 address printed in the usual style as 8 groups of up to 4 hex digits separated by colons and followed by a colon and up to 5 digits of port number is 46 characters -- compare to 22 characters for the equivalent maximum with IPv4 addresses + port number printed in the usual style, the 'FOREIGN ADDRESS' column could be constrained to start at column 82. >How-To-Repeat: >Fix: --- sockstat.diff begins here --- --- usr.bin/sockstat/sockstat.c.orig 2007-12-25 18:26:12.000000000 +0000 +++ usr.bin/sockstat/sockstat.c 2007-12-25 18:27:19.000000000 +0000 @@ -609,6 +609,7 @@ case AF_INET: case AF_INET6: pos += printaddr(s->family, &s->laddr); + pos += xprintf(" "); while (pos < 58) pos += xprintf(" "); pos += printaddr(s->family, &s->faddr); --- sockstat.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200712251849.lBPInF76005918>