aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2015-05-22 20:22:55 +0200
committerest31 <MTest31@outlook.com>2015-05-22 20:24:39 +0200
commite13d2bafc6d0a4fb0d42cf9c229012f4a4f17131 (patch)
tree93c98e315e1d4b5ac08bed541d71bdc8271a1ce3 /src
parent9facb40738e7c51c838ad2ccffd96028862160cb (diff)
downloadminetest-e13d2bafc6d0a4fb0d42cf9c229012f4a4f17131.tar.gz
minetest-e13d2bafc6d0a4fb0d42cf9c229012f4a4f17131.tar.bz2
minetest-e13d2bafc6d0a4fb0d42cf9c229012f4a4f17131.zip
Deny empty username early in the protocol
Thanks to @UltimateNate for pointing this out :)
Diffstat (limited to 'src')
-rw-r--r--src/network/serverpackethandler.cpp8
1 files changed, 5 insertions, 3 deletions
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;
}