aboutsummaryrefslogtreecommitdiff
path: root/src/p2p
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2019-04-16 22:38:55 +0200
committerRiccardo Spagni <ric@spagni.net>2019-04-16 22:38:56 +0200
commit8d16e92dcb6158ac77b2e36ffc4952999192d48f (patch)
tree2d6032a89cf18120fb8ceed41abfe2022464256b /src/p2p
parentMerge pull request #5424 (diff)
parentp2p: fix integer overflow in host bans (diff)
downloadmonero-8d16e92dcb6158ac77b2e36ffc4952999192d48f.tar.xz
Merge pull request #5425
58585986 p2p: fix integer overflow in host bans (moneromooo-monero)
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 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