Subject: netstat prints negative port numbers + FIX (#193) Index: ucb/netstat/inet.c 2.11BSD Description: Port numbers are 'u_short' - they should never show up as negative in a netstat display. Repeat-By: Have a connection with a port number higher than 32767 present. Do a 'netstat' and notice that the port numbers show up as negative. Fix: Some systems (i noticed this some time ago with Multics systems) allocate port numbers from the high range on down - they start at 50000 or 60000 and work down rather than from 1024 and going up. It is a trivial fix - changing a '%d' to a '%u' to correctly handle the port number as unsigned. Save the following to a file (/tmp/foo). Then: patch -p0 < /tmp/foo cd /usr/src/ucb/netstat make make install make clean ===================cut here *** /usr/src/ucb/netstat/inet.c.old Sun Feb 20 20:45:15 1994 --- /usr/src/ucb/netstat/inet.c Sun Aug 28 10:53:19 1994 *************** *** 11,17 **** */ #if defined(DOSCCS) && !defined(lint) ! static char sccsid[] = "@(#)inet.c 5.9.2 (2.11BSD GTE) 1/1/94"; #endif #include --- 11,17 ---- */ #if defined(DOSCCS) && !defined(lint) ! static char sccsid[] = "@(#)inet.c 5.9.3 (2.11BSD GTE) 8/28/94"; #endif #include *************** *** 359,365 **** if (sp || port == 0) sprintf(cp, "%.8s", sp ? sp->s_name : "*"); else ! sprintf(cp, "%d", ntohs((u_short)port)); width = Aflag ? 18 : 22; printf(" %-*.*s", width, width, line); } --- 359,365 ---- if (sp || port == 0) sprintf(cp, "%.8s", sp ? sp->s_name : "*"); else ! sprintf(cp, "%u", ntohs((u_short)port)); width = Aflag ? 18 : 22; printf(" %-*.*s", width, width, line); }