1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-14 19:59:02 +00:00

Change o.TimeSinceStartMS returning milliseconds to o.TimeSinceStart

returning floating-point seconds. Everywhere o.TimeSinceStartMS was
called, the return value was being divided by 1000.0, which had the same
effect but would overflow when the difference exceeded about 25 days
(2^31 milliseconds). This patch is by Daniel Miller.
This commit is contained in:
david
2011-03-28 20:34:32 +00:00
parent 0fb893af03
commit 7453ec34d0
7 changed files with 20 additions and 17 deletions

View File

@@ -2193,7 +2193,7 @@ void printStatusMessage() {
// Pre-computations
struct timeval tv;
gettimeofday(&tv, NULL);
int time = (int) (o.TimeSinceStartMS(&tv) / 1000.0);
int time = (int) (o.TimeSinceStart(&tv));
log_write(LOG_STDOUT, "Stats: %d:%02d:%02d elapsed; %d hosts completed (%d up), %d undergoing %s\n",
time / 60 / 60, time / 60 % 60, time % 60, o.numhosts_scanned,
@@ -2213,13 +2213,13 @@ void print_xml_finished_open(time_t timep, const struct timeval *tv) {
xml_open_start_tag("finished");
xml_attribute("time", "%lu", (unsigned long) timep);
xml_attribute("timestr", "%s", mytime);
xml_attribute("elapsed", "%.2f", o.TimeSinceStartMS(tv) / 1000.0);
xml_attribute("elapsed", "%.2f", o.TimeSinceStart(tv));
xml_attribute("summary",
"Nmap done at %s; %d %s (%d %s up) scanned in %.2f seconds",
mytime, o.numhosts_scanned,
(o.numhosts_scanned == 1) ? "IP address" : "IP addresses",
o.numhosts_up, (o.numhosts_up == 1) ? "host" : "hosts",
o.TimeSinceStartMS(tv) / 1000.0);
o.TimeSinceStart(tv));
}
void print_xml_hosts() {
@@ -2264,7 +2264,7 @@ void printfinaloutput() {
o.numhosts_scanned,
(o.numhosts_scanned == 1) ? "IP address" : "IP addresses",
o.numhosts_up, (o.numhosts_up == 1) ? "host" : "hosts",
o.TimeSinceStartMS(&tv) / 1000.0);
o.TimeSinceStart(&tv));
if (o.verbose && o.isr00t && o.RawScan())
log_write(LOG_STDOUT | LOG_SKID, " %s\n",
getFinalPacketStats(statbuf, sizeof(statbuf)));
@@ -2286,7 +2286,7 @@ void printfinaloutput() {
mytime, o.numhosts_scanned,
(o.numhosts_scanned == 1) ? "IP address" : "IP addresses",
o.numhosts_up, (o.numhosts_up == 1) ? "host" : "hosts",
o.TimeSinceStartMS(&tv) / 1000.0);
o.TimeSinceStart(&tv));
xml_end_tag(); /* nmaprun */
xml_newline();