Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Oct 2009 14:55:38 +0100 (BST)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r198118 - head/usr.bin/netstat
Message-ID:  <alpine.BSF.2.00.0910181454400.78183@fledge.watson.org>
In-Reply-To: <20091016154905.E8438@delplex.bde.org>
References:  <200910151031.n9FAVOvU070664@svn.freebsd.org> <20091016154905.E8438@delplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.0910181454400.78183>