Only consider sockets that are in valid states as identd candidates

When an identd query happens, we check all the connected sockets for their
local and remote ports, to compare them with the query.  But we MUST only
consider the connected ones because:

- It doesn’t make sense to answer for a connection that has just been closed
- A non-connected sockets is not in a valid state for this (specifically
  here: its ::port attribute is empty)

fix #3421
This commit is contained in:
louiz’
2020-02-25 22:53:37 +01:00
parent b18d81ae9f
commit 23f3f48b4a
+3 -1
View File
@@ -263,6 +263,8 @@ std::string TCPClientSocketHandler::get_port() const
bool TCPClientSocketHandler::match_port_pair(const uint16_t local, const uint16_t remote) const bool TCPClientSocketHandler::match_port_pair(const uint16_t local, const uint16_t remote) const
{ {
if (!this->is_connected())
return false;
const auto remote_port = static_cast<uint16_t>(std::stoi(this->port)); const auto remote_port = static_cast<uint16_t>(std::stoi(this->port));
return this->is_connected() && local == this->local_port && remote == remote_port; return local == this->local_port && remote == remote_port;
} }