Nmap Development mailing list archives

Re: [PATCH] timing.cc integer overflow


From: David Fifield <david () bamsoftware com>
Date: Wed, 11 Feb 2009 10:50:27 -0700

On Mon, Feb 09, 2009 at 08:19:06PM +0100, Henri Doreau wrote:
Thanks, I have committed this patch. However I think there's still some
work to do. The member function ScanProgressMeter::printStatsIfNecessary
does some of the same calculations as ScanProgressMeter::printStats, and
it still does them with longs. I don't know what the effect would be,
but it could cause the stats not to be printed when they should be, or
vice versa. Can you look at that function and do the calculations in the
same way, or (even better) remove the duplicated code into a separate
function?

I have added a (public) method: ScanProgressMeter::estimateTimeLeft that
returns a double. It "factorizes" the duplicated code for both
ScanProgressMeter::printStatsIfNecessary and ScanProgressMeter::printStats.
So the patch contains a modified version of
ScanProgressMeter::printStatsIfNecessary, and the same way,
ScanProgressMeter::mayBePrinted was changed to compute things in seconds
only.

I applied your patch with minor changes. I made estimateTimeLeft into a
static function within timing.cc. The little trick where 0.5 is added to
the remaining time to get the effect of rounding in integer
calculations, I moved out of estimateTimeLeft, to just before the
integer calculations are done.

David Fifield

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org


Current thread: