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

Bruce Evans brde at optusnet.com.au
Fri Oct 16 04:58:10 UTC 2009


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.

Bruce


More information about the svn-src-all mailing list