mirror of
				https://github.com/luanti-org/luanti.git
				synced 2025-10-31 07:25:22 +01:00 
			
		
		
		
	Fix race condition in registration leading to duplicate create_auth calls
This commit is contained in:
		| @@ -1496,8 +1496,19 @@ void Server::handleCommand_FirstSrp(NetworkPacket* pkt) | |||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		std::string initial_ver_key; | 		std::string initial_ver_key; | ||||||
| 
 |  | ||||||
| 		initial_ver_key = encode_srp_verifier(verification_key, salt); | 		initial_ver_key = encode_srp_verifier(verification_key, salt); | ||||||
|  | 
 | ||||||
|  | 		// It is possible for multiple connections to get this far with the same
 | ||||||
|  | 		// player name. In the end only one player with a given name will be emerged
 | ||||||
|  | 		// (see Server::StateTwoClientInit) but we still have to be careful here.
 | ||||||
|  | 		if (m_script->getAuth(playername, nullptr, nullptr)) { | ||||||
|  | 			// Another client beat us to it
 | ||||||
|  | 			actionstream << "Server: Client from " << addr_s | ||||||
|  | 				<< " tried to register " << playername << " a second time." | ||||||
|  | 				<< std::endl; | ||||||
|  | 			DenyAccess(peer_id, SERVER_ACCESSDENIED_ALREADY_CONNECTED); | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
| 		m_script->createAuth(playername, initial_ver_key); | 		m_script->createAuth(playername, initial_ver_key); | ||||||
| 		m_script->on_authplayer(playername, addr_s, true); | 		m_script->on_authplayer(playername, addr_s, true); | ||||||
| 
 | 
 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user