mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Ensure unique client GUIDs. Patch by sbirmi, fixes #3949.
Two clients chosing the same GUID is highly unlikely, yet possible. A malicious client chosing an existing GUID would have resulted in unassigning the player with that GUID. This was SVN commit r19225.
This commit is contained in:
@@ -903,6 +903,7 @@ bool CNetServerWorker::OnAuthenticate(void* context, CFsmEvent* event)
|
||||
|
||||
CAuthenticateMessage* message = (CAuthenticateMessage*)event->GetParamRef();
|
||||
CStrW username = SanitisePlayerName(message->m_Name);
|
||||
CStr guid = message->m_GUID;
|
||||
|
||||
// Either deduplicate or prohibit join if name is in use
|
||||
bool duplicatePlayernames = false;
|
||||
@@ -919,6 +920,16 @@ bool CNetServerWorker::OnAuthenticate(void* context, CFsmEvent* event)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Disconnect user if the provided GUID is already in use
|
||||
if (std::find_if(
|
||||
server.m_Sessions.begin(), server.m_Sessions.end(),
|
||||
[&guid] (const CNetServerSession* session)
|
||||
{ return session->GetGUID() == guid; }) != server.m_Sessions.end())
|
||||
{
|
||||
session->Disconnect(NDR_PLAYERGUID_IN_USE);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Disconnect banned usernames
|
||||
if (std::find(server.m_BannedPlayers.begin(), server.m_BannedPlayers.end(), username) != server.m_BannedPlayers.end())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user