703rc/fix port size (#802)

* validate port numbers in client

* validate port numbers created at virtual servers and receiver process as tcp ports
This commit is contained in:
2023-09-18 08:59:53 +02:00
committed by GitHub
parent b367b7e431
commit 48759f440e
12 changed files with 148 additions and 11 deletions

View File

@ -88,5 +88,5 @@ IpAddr HostnameToIp(const char *hostname);
std::string IpToInterfaceName(const std::string &ip);
MacAddr InterfaceNameToMac(const std::string &inf);
IpAddr InterfaceNameToIp(const std::string &ifn);
void validatePortNumber(int port);
} // namespace sls

View File

@ -203,4 +203,13 @@ MacAddr InterfaceNameToMac(const std::string &inf) {
return MacAddr(mac);
}
void validatePortNumber(int port) {
if (0 >= port || port > std::numeric_limits<uint16_t>::max()) {
std::ostringstream oss;
oss << "Invalid port number " << port << ". It must be in range 1 - "
<< std::numeric_limits<uint16_t>::max();
throw RuntimeError(oss.str());
}
}
} // namespace sls