Skip to content

Commit

Permalink
Deny empty username early in the protocol
Browse files Browse the repository at this point in the history
Thanks to @UltimateNate for pointing this out :)
  • Loading branch information
est31 committed May 22, 2015
1 parent 9facb40 commit e13d2ba
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/network/serverpackethandler.cpp
Expand Up @@ -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;
}
Expand Down

1 comment on commit e13d2ba

@nerzhul
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.