mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Manipulations of remote_endpoint must be done in a try/catch
block to avoid race conditions.
This commit is contained in:
@@ -278,9 +278,21 @@ void Peer::handleConnect(const boost::system::error_code& error, boost::asio::ip
|
|||||||
// - We don't bother remembering the inbound IP or port. Only useful for debugging.
|
// - We don't bother remembering the inbound IP or port. Only useful for debugging.
|
||||||
void Peer::connected(const boost::system::error_code& error)
|
void Peer::connected(const boost::system::error_code& error)
|
||||||
{
|
{
|
||||||
boost::asio::ip::tcp::endpoint ep = getSocket().remote_endpoint();
|
boost::asio::ip::tcp::endpoint ep;
|
||||||
int iPort = ep.port();
|
int iPort;
|
||||||
std::string strIp = ep.address().to_string();
|
std::string strIp;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ep = getSocket().remote_endpoint();
|
||||||
|
iPort = ep.port();
|
||||||
|
strIp = ep.address().to_string();
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
detach("edc", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mClientConnect = false;
|
mClientConnect = false;
|
||||||
mIpPortConnect = make_pair(strIp, iPort);
|
mIpPortConnect = make_pair(strIp, iPort);
|
||||||
|
|||||||
@@ -50,11 +50,19 @@ void RPCDoor::handleConnect(RPCServer::pointer new_connection,
|
|||||||
if (!error)
|
if (!error)
|
||||||
{
|
{
|
||||||
// Restrict callers by IP
|
// Restrict callers by IP
|
||||||
|
try
|
||||||
|
{
|
||||||
if (!isClientAllowed(new_connection->getSocket().remote_endpoint().address().to_string()))
|
if (!isClientAllowed(new_connection->getSocket().remote_endpoint().address().to_string()))
|
||||||
{
|
{
|
||||||
startListening();
|
startListening();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{ // client may have disconnected
|
||||||
|
startListening();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
new_connection->connected();
|
new_connection->connected();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,8 +142,14 @@ public:
|
|||||||
{
|
{
|
||||||
boost::mutex::scoped_lock sl(mMapLock);
|
boost::mutex::scoped_lock sl(mMapLock);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
mMap[cpClient] = boost::make_shared< WSConnection<endpoint_type> >(this, cpClient);
|
mMap[cpClient] = boost::make_shared< WSConnection<endpoint_type> >(this, cpClient);
|
||||||
}
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void on_pong(connection_ptr cpClient, std::string data)
|
void on_pong(connection_ptr cpClient, std::string data)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user