1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 13:11:28 +00:00

Replaces floating-point arithmetic with integers to avoid theoretical

overflows. As a side effect it silences current MSVC compiler warning about
"possible loss of data". See #995
This commit is contained in:
nnposter
2017-09-23 23:17:14 +00:00
parent ec0007c444
commit 8f54ffa15d

View File

@@ -1495,8 +1495,8 @@ int FPHost::update_RTO(int measured_rtt_usecs, bool retransmission) {
*
* RTO <- SRTT + max (G, K*RTTVAR)
*/
this->rttvar = ((1.0 - 0.25) * this->rttvar) + (0.25 * ABS(this->srtt - measured_rtt_usecs));
this->srtt = ((1.0 - 0.125) * this->srtt) + (0.125 * measured_rtt_usecs);
this->rttvar += (ABS(this->srtt - measured_rtt_usecs) - this->rttvar) >> 2;
this->srtt += (measured_rtt_usecs - this->srtt) >> 3;
this->rto = this->srtt + MAX(500000, 4*this->rttvar);
}