From 5858598604c511ff57a434196d27acf2f49cf23f Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 11 Apr 2019 21:57:51 +0000 Subject: p2p: fix integer overflow in host bans --- src/p2p/net_node.inl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/p2p') 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::max() - seconds) + limit = std::numeric_limits::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 -- cgit v1.2.3