Skip to content

Commit e13d2ba

Browse files
committedMay 22, 2015
Deny empty username early in the protocol
Thanks to @UltimateNate for pointing this out :)
1 parent 9facb40 commit e13d2ba

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

‎src/network/serverpackethandler.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,11 @@ void Server::handleCommand_Init(NetworkPacket* pkt)
164164
*/
165165
const char* playername = playerName.c_str();
166166

167-
if (playerName.size() > PLAYERNAME_SIZE) {
168-
actionstream << "Server: Player with an too long name "
169-
<< "tried to connect from " << addr_s << std::endl;
167+
size_t pns = playerName.size();
168+
if (pns == 0 || pns > PLAYERNAME_SIZE) {
169+
actionstream << "Server: Player with "
170+
<< ((pns > PLAYERNAME_SIZE) ? "a too long" : "an empty")
171+
<< " name tried to connect from " << addr_s << std::endl;
170172
DenyAccess(pkt->getPeerId(), SERVER_ACCESSDENIED_WRONG_NAME);
171173
return;
172174
}

1 commit comments

Comments
 (1)

nerzhul commented on May 23, 2015

@nerzhul
Contributor

👍

Please sign in to comment.