p2p: fix integer overflow in host bans

This commit is contained in:
moneromooo-monero 2019-04-11 21:57:51 +00:00
parent 9c77dbf376
commit 5858598604
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
2 changed files with 25 additions and 13 deletions

View file

@ -176,8 +176,15 @@ namespace nodetool
if(!addr.is_blockable())
return false;
const time_t now = time(nullptr);
CRITICAL_REGION_LOCAL(m_blocked_hosts_lock);
m_blocked_hosts[addr.host_str()] = time(nullptr) + seconds;
time_t limit;
if (now > std::numeric_limits<time_t>::max() - seconds)
limit = std::numeric_limits<time_t>::max();
else
limit = now + seconds;
m_blocked_hosts[addr.host_str()] = limit;
// drop any connection to that address. This should only have to look into
// the zone related to the connection, but really make sure everything is