Deny empty username early in the protocol

Thanks to @UltimateNate for pointing this out :)
This commit is contained in:
est31 2015-05-22 20:22:55 +02:00 committed by OttoLidenbrock
parent 009e8b1058
commit 4cd8e420a2
1 changed files with 5 additions and 3 deletions

View File

@ -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;
}