From owner-freebsd-bugs@FreeBSD.ORG Tue Dec 25 18:50:02 2007 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CF04B16A419 for ; Tue, 25 Dec 2007 18:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 94B1D13C44B for ; Tue, 25 Dec 2007 18:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id lBPIo2Kj096801 for ; Tue, 25 Dec 2007 18:50:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id lBPIo2Bn096800; Tue, 25 Dec 2007 18:50:02 GMT (envelope-from gnats) Resent-Date: Tue, 25 Dec 2007 18:50:02 GMT Resent-Message-Id: <200712251850.lBPIo2Bn096800@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Matthew Seaman Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6FD1016A417 for ; Tue, 25 Dec 2007 18:49:22 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (gate6.infracaninophile.co.uk [IPv6:2001:8b0:151:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id AD3A413C458 for ; Tue, 25 Dec 2007 18:49:21 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [IPv6:::1]) by smtp.infracaninophile.co.uk (8.14.2/8.14.2) with ESMTP id lBPInGPa005919 for ; Tue, 25 Dec 2007 18:49:16 GMT (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost) by happy-idiot-talk.infracaninophile.co.uk (8.14.2/8.14.2/Submit) id lBPInF76005918; Tue, 25 Dec 2007 18:49:15 GMT (envelope-from matthew) Message-Id: <200712251849.lBPInF76005918@happy-idiot-talk.infracaninophile.co.uk> Date: Tue, 25 Dec 2007 18:49:15 GMT From: Matthew Seaman To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/119014: [patch] IPv6 addresses cause sockstat(1) to run columns together X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Matthew Seaman List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Dec 2007 18:50:02 -0000 >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: