svn commit: r198118 - head/usr.bin/netstat

Robert Watson rwatson at
Sun Oct 18 13:55:38 UTC 2009

On Fri, 16 Oct 2009, Bruce Evans wrote:

> On Thu, 15 Oct 2009, Robert Watson wrote:
>> Log:
>>  Print routing statistics as unsigned short rather than unsigned int,
>>  otherwise sign extension leads to unlikely values when in the negative
>>  range of the signed short structure fields that hold the statistics.
>>  The type used to hold routing statistics is arguably also incorrect.
> This enlarges the bug.  With signed types you get advance warning of 
> overflow (you actually get overflow earlier but it usually just results in 
> obviously wrong values being printed), and repeated warnings on overflow 
> (every time the overflowing values wrap back to negative). With unsigned 
> types or this change, you get unobviously wrong values after the first 
> overflow, and no repeated warnings (unless you watch the values carefully 
> enough to see them go backwards).  Using unsigned bytes only delays the 
> overflow for a whole factor of 2.

Yes, a preferable fix would be to move to a u_long (or the like) for the 
statistics, but unfortunately it's too late in the game to fix that for 8.0. 
I'll change the statistics types in 9.0 at some point.

Robert N M Watson
Computer Laboratory
University of Cambridge

More information about the svn-src-all mailing list