1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-25 00:49:01 +00:00

Avoid integer overflow in nping elapsedRuntime. Fixes #1961

This commit is contained in:
dmiller
2020-03-11 21:24:56 +00:00
parent 4097f39090
commit f83de100b3
2 changed files with 3 additions and 1 deletions

View File

@@ -190,7 +190,7 @@ double NpingTimer::elapsed(struct timeval *now){
gettimeofday(&tv, NULL);
end_tv = &tv;
}
return TIMEVAL_SUBTRACT(*end_tv, start_tv) / 1000000.0;
return TIMEVAL_FSEC_SUBTRACT(*end_tv, start_tv);
}

View File

@@ -180,6 +180,8 @@
#define TIMEVAL_MSEC_SUBTRACT(a,b) ((((a).tv_sec - (b).tv_sec) * 1000) + ((a).tv_usec - (b).tv_usec) / 1000)
/* Timeval subtract in seconds; truncate towards zero */
#define TIMEVAL_SEC_SUBTRACT(a,b) ((a).tv_sec - (b).tv_sec + (((a).tv_usec < (b).tv_usec) ? - 1 : 0))
/* Timeval subtract in fractional seconds; convert to float */
#define TIMEVAL_FSEC_SUBTRACT(a,b) ((a).tv_sec - (b).tv_sec + (((a).tv_usec - (b).tv_usec)/1000000.0))
class NpingTimer {