Bug#574409: net-tools: netstat uses hard-coded display width

Garrett Wollman wollman at csail.mit.edu
Wed Mar 17 23:18:38 UTC 2010


Package: net-tools
Version: 1.60-22
Severity: normal


netstat (in its default output mode) does not adapt properly to
terminal width; it always truncates hostnames for an 80-column display
even when the terminal settings (`stty size`) and the COLUMNS
environment variable are set to a different size.  This is a problem
for both narrower and wider terminals; for example:

Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 metroplex.csail.m:imap2 pool-173-48-166-4:53554 ESTABLISHED

(on a terminal that is 141 characters wide)

tcp        0      0 foghorn-leghorn.c:54302 postgres-1.c:postgr
esql ESTABLISHED

(on a terminal that is 63 characters wide)

The bug is not sensitive to whether the output is a tty or a pipe.
The 4BSD version of netstat(1) suffers from the same bug, although
with slightly different choices.  The bug was also in etch.

The -W flag is a workaround for script input but produces unreadable output.

Fix:

Most of the columns output by netstat are of fixed length.  Only the
columns containing hostnames should vary in width.  So, if
ioctl(TIOCGWINSZ) does not set errno to ENOTTY, or the environment
variable COLUMNS is set, the width of the hostname columns should be
equal to half of the display width less the total width of the
fixed-width columns.

-- System Information:
Debian Release: 5.0.3
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages net-tools depends on:
ii  libc6                       2.7-18lenny2 GNU C Library: Shared libraries

net-tools recommends no packages.

net-tools suggests no packages.

-- no debconf information





More information about the Pkg-net-tools-maintainers mailing list