From m.seaman@infracaninophile.co.uk  Tue Dec 25 18:49:22 2007
Return-Path: <m.seaman@infracaninophile.co.uk>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6FD1016A417
	for <FreeBSD-gnats-submit@freebsd.org>; 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 <FreeBSD-gnats-submit@freebsd.org>; 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 <FreeBSD-gnats-submit@freebsd.org>; 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 <m.seaman@infracaninophile.co.uk>
Reply-To: Matthew Seaman <m.seaman@infracaninophile.co.uk>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] IPv6 addresses cause sockstat(1) to run columns together
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>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:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 25 18:50:02 UTC 2007
>Closed-Date:    Fri May 14 08:05:52 UTC 2010
>Last-Modified:  Fri May 14 08:05:52 UTC 2010
>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:
State-Changed-From-To: open->closed 
State-Changed-By: maxim 
State-Changed-When: Fri May 14 08:05:11 UTC 2010 
State-Changed-Why:  
It was reported the bug was fixed by bin/145194. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=119014 
>Unformatted:
