Skip to content
Snippets Groups Projects
Commit e13d2baf authored by est31's avatar est31
Browse files

Deny empty username early in the protocol

Thanks to @UltimateNate for pointing this out :)
parent 9facb407
No related branches found
No related tags found
No related merge requests found
......@@ -164,9 +164,11 @@ void Server::handleCommand_Init(NetworkPacket* pkt)
*/
const char* playername = playerName.c_str();
if (playerName.size() > PLAYERNAME_SIZE) {
actionstream << "Server: Player with an too long name "
<< "tried to connect from " << addr_s << std::endl;
size_t pns = playerName.size();
if (pns == 0 || pns > PLAYERNAME_SIZE) {
actionstream << "Server: Player with "
<< ((pns > PLAYERNAME_SIZE) ? "a too long" : "an empty")
<< " name tried to connect from " << addr_s << std::endl;
DenyAccess(pkt->getPeerId(), SERVER_ACCESSDENIED_WRONG_NAME);
return;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment