1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-24 16:39:03 +00:00

Avoid integer overflow in multiplication. See #1834

This commit is contained in:
dmiller
2019-12-29 05:15:10 +00:00
parent d5b57a8cd9
commit b74f70fb33

View File

@@ -3118,7 +3118,15 @@ int NpingOps::echoPayload(bool value){
int NpingOps::getTotalProbes(){
int total_ports=0;
this->getTargetPorts(&total_ports);
return this->getPacketCount() * total_ports * this->targets.Targets.size();
u64 tmp = (u64) this->getPacketCount() * total_ports;
if (tmp > INT_MAX) {
return -1;
}
tmp *= this->targets.Targets.size();
if (tmp > INT_MAX) {
return -1;
}
return (int) tmp;
}