prevent port values to go below 1024 in the backend

This commit is contained in:
csoler 2017-02-27 22:37:27 +01:00
parent 30c4dfe218
commit f70cbbe065

View File

@ -901,6 +901,12 @@ bool p3Peers::setLocalAddress(const RsPeerId &id, const std::string &addr_str,
std::cerr << "p3Peers::setLocalAddress() " << id << std::endl;
#endif
if(port < 1024)
{
std::cerr << "(EE) attempt to use a port that is reserved to the system: " << port << std::endl;
return false ;
}
struct sockaddr_storage addr;
struct sockaddr_in *addrv4p = (struct sockaddr_in *) &addr;
addrv4p->sin_family = AF_INET;
@ -926,6 +932,12 @@ bool p3Peers::setExtAddress(const RsPeerId &id, const std::string &addr_str, ui
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setExtAddress() " << id << std::endl;
#endif
if(port < 1024)
{
std::cerr << "(EE) attempt to use a port that is reserved to the system: " << port << std::endl;
return false ;
}
// NOTE THIS IS IPV4 FOR NOW.
struct sockaddr_storage addr;