Fix: Thread unsafe use of NetworkAddress::GetAddressAsString
Remove static buffer form of NetworkAddress::GetAddressAsString. This is used in multiple threads concurrently, and is not thread-safe. Replace it with a form returning std::string.
This commit is contained in:

committed by
Charles Pigott

parent
9aca6ff971
commit
1ac0d4a5b2
@@ -244,7 +244,7 @@ void ServerNetworkUDPSocketHandler::Receive_CLIENT_GET_NEWGRFS(Packet *p, Networ
|
||||
uint8 in_reply_count = 0;
|
||||
size_t packet_len = 0;
|
||||
|
||||
DEBUG(net, 6, "[udp] newgrf data request from %s", client_addr->GetAddressAsString());
|
||||
DEBUG(net, 6, "[udp] newgrf data request from %s", client_addr->GetAddressAsString().c_str());
|
||||
|
||||
num_grfs = p->Recv_uint8 ();
|
||||
if (num_grfs > NETWORK_MAX_GRF_COUNT) return;
|
||||
@@ -307,7 +307,7 @@ void ClientNetworkUDPSocketHandler::Receive_SERVER_RESPONSE(Packet *p, NetworkAd
|
||||
/* Just a fail-safe.. should never happen */
|
||||
if (_network_udp_server) return;
|
||||
|
||||
DEBUG(net, 4, "[udp] server response from %s", client_addr->GetAddressAsString());
|
||||
DEBUG(net, 4, "[udp] server response from %s", client_addr->GetAddressAsString().c_str());
|
||||
|
||||
/* Find next item */
|
||||
item = NetworkGameListAddItem(*client_addr);
|
||||
@@ -407,7 +407,7 @@ void ClientNetworkUDPSocketHandler::Receive_SERVER_NEWGRFS(Packet *p, NetworkAdd
|
||||
uint8 num_grfs;
|
||||
uint i;
|
||||
|
||||
DEBUG(net, 6, "[udp] newgrf data reply from %s", client_addr->GetAddressAsString());
|
||||
DEBUG(net, 6, "[udp] newgrf data reply from %s", client_addr->GetAddressAsString().c_str());
|
||||
|
||||
num_grfs = p->Recv_uint8 ();
|
||||
if (num_grfs > NETWORK_MAX_GRF_COUNT) return;
|
||||
@@ -477,7 +477,7 @@ void NetworkUDPQueryMasterServer()
|
||||
|
||||
_udp_client_socket->SendPacket(&p, &out_addr, true);
|
||||
|
||||
DEBUG(net, 2, "[udp] master server queried at %s", out_addr.GetAddressAsString());
|
||||
DEBUG(net, 2, "[udp] master server queried at %s", out_addr.GetAddressAsString().c_str());
|
||||
}
|
||||
|
||||
/** Find all servers */
|
||||
@@ -541,8 +541,8 @@ static void NetworkUDPAdvertiseThread()
|
||||
if (_session_key == 0 && session_key_retries++ == 2) {
|
||||
DEBUG(net, 0, "[udp] advertising to the master server is failing");
|
||||
DEBUG(net, 0, "[udp] we are not receiving the session key from the server");
|
||||
DEBUG(net, 0, "[udp] please allow udp packets from %s to you to be delivered", out_addr.GetAddressAsString(false));
|
||||
DEBUG(net, 0, "[udp] please allow udp packets from you to %s to be delivered", out_addr.GetAddressAsString(false));
|
||||
DEBUG(net, 0, "[udp] please allow udp packets from %s to you to be delivered", out_addr.GetAddressAsString(false).c_str());
|
||||
DEBUG(net, 0, "[udp] please allow udp packets from you to %s to be delivered", out_addr.GetAddressAsString(false).c_str());
|
||||
}
|
||||
if (_session_key != 0 && _network_advertise_retries == 0) {
|
||||
DEBUG(net, 0, "[udp] advertising to the master server is failing");
|
||||
|
Reference in New Issue
Block a user