From 9fe196bb0b0906d25e6163460a1324ece6649f7d Mon Sep 17 00:00:00 2001 From: david Date: Wed, 17 Dec 2008 02:48:14 +0000 Subject: [PATCH] o Fixed a division by zero error in the packet rate measuring code that could cause a display of infinity packets per seconds near the start of a scan. [Jah] --- CHANGELOG | 4 ++++ timing.cc | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index c78a27faa..9f683cc76 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ # Nmap Changelog ($Id$); -*-text-*- +o Fixed a division by zero error in the packet rate measuring code + that could cause a display of infinity packets per seconds near the + start of a scan. [Jah] + o Complete re-write of the marshalling logic for Microsoft RPC calls. [Ron Bowes] diff --git a/timing.cc b/timing.cc index ef45a3a25..ac278103e 100644 --- a/timing.cc +++ b/timing.cc @@ -349,7 +349,13 @@ void RateMeter::update(double amount, const struct timeval *now) { } double RateMeter::getOverallRate(const struct timeval *now) const { - return total / elapsedTime(now); + double elapsed; + + elapsed = elapsedTime(now); + if (elapsed <= 0.0) + return 0.0; + else + return total / elapsed; } /* Get the "current" rate (actually a moving average of the last