diff options
author | Riccardo Spagni <ric@spagni.net> | 2019-04-16 22:38:55 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2019-04-16 22:38:56 +0200 |
commit | 8d16e92dcb6158ac77b2e36ffc4952999192d48f (patch) | |
tree | 2d6032a89cf18120fb8ceed41abfe2022464256b /src/p2p/net_node.inl | |
parent | Merge pull request #5424 (diff) | |
parent | p2p: fix integer overflow in host bans (diff) | |
download | monero-8d16e92dcb6158ac77b2e36ffc4952999192d48f.tar.xz |
Merge pull request #5425
58585986 p2p: fix integer overflow in host bans (moneromooo-monero)
Diffstat (limited to 'src/p2p/net_node.inl')
-rw-r--r-- | src/p2p/net_node.inl | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 7d13b3216..be97edbe5 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -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 |