Nmap Development mailing list archives

Re: [PATCH] timing.cc integer overflow


From: Henri Doreau <henri.doreau () gmail com>
Date: Mon, 9 Feb 2009 20:19:06 +0100

Hello,

Comments inline.

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.


Here's something I can't explain. Look at the results for 10 days
elapsed with 10% completion. That gives a completion date 100 days after
the start of the timer, which in the test code is set to 0:00:00,
January 1, 2009. For me the local time 100 days after the start of the
year will be 1:00 (or 0:59, that's just a rounding issue). That makes
sense, because that's April 10 and daylight savings time will have
started in the mountain time zone. But for you the local time of day
will be 23:00? Is there a time zone that moves the clock backwards that
time of year?

 10 days elapsed
 TEST Timing: About 0.00% done
-TEST Timing: About 10.00% done; ETC: 23:00 (2160:00:00 remaining)
-TEST Timing: About 20.00% done; ETC: 00:00 (960:00:00 remaining)
+TEST Timing: About 10.00% done; ETC: 00:59 (2159:59:59 remaining)
+TEST Timing: About 20.00% done; ETC: 23:59 (959:59:59 remaining)
 TEST Timing: About 30.00% done; ETC: 08:00 (560:00:00 remaining)

Filling the t structure with zeros solves the problem : struct tm t = {0};
Cheers
Henri

Attachment: timing.h.patch
Description:

Attachment: timing.cc.patch
Description:


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

Current thread: