From: est31 Date: Fri, 22 May 2015 18:22:55 +0000 (+0200) Subject: Deny empty username early in the protocol X-Git-Tag: 0.4.13~241 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e13d2bafc6d0a4fb0d42cf9c229012f4a4f17131;p=oweals%2Fminetest.git Deny empty username early in the protocol Thanks to @UltimateNate for pointing this out :) --- diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp index f658e106f..4633aba86 100644 --- a/src/network/serverpackethandler.cpp +++ b/src/network/serverpackethandler.cpp @@ -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; }