aboutsummaryrefslogtreecommitdiff
path: root/src/p2p
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-04-11 21:57:51 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-04-11 21:59:27 +0000
commit5858598604c511ff57a434196d27acf2f49cf23f (patch)
tree413bc4617ed03a2e86610cfeeda004dfabd2b783 /src/p2p
parentMerge pull request #5386 (diff)
downloadmonero-5858598604c511ff57a434196d27acf2f49cf23f.tar.xz
p2p: fix integer overflow in host bans
Diffstat (limited to 'src/p2p')
-rw-r--r--src/p2p/net_node.inl9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index f0aef384f..0c89c8f4b 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