Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp
index f658e10..1b27903 100644
--- a/src/network/serverpackethandler.cpp
+++ b/src/network/serverpackethandler.cpp
@@ -164,6 +164,13 @@ void Server::handleCommand_Init(NetworkPacket* pkt)
*/
const char* playername = playerName.c_str();
+ if (playerName.size() == 0) {
+ actionstream << "Server: Player with an empty name "
+ << "tried to connect from " << addr_s << std::endl;
+ DenyAccess(pkt->getPeerId(), SERVER_ACCESSDENIED_WRONG_NAME);
+ return;
+ }
+
if (playerName.size() > PLAYERNAME_SIZE) {
actionstream << "Server: Player with an too long name "
<< "tried to connect from " << addr_s << std::endl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment