aboutsummaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/server.cpp b/src/server.cpp
index 9bd8e70f3..93d00f369 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -1448,14 +1448,21 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
/*
Set up player
*/
-
- // Get player name
char playername[PLAYERNAME_SIZE];
- for(u32 i=0; i<PLAYERNAME_SIZE-1; i++)
- {
- playername[i] = data[3+i];
+ unsigned int playername_length = 0;
+ for (; playername_length < PLAYERNAME_SIZE; playername_length++ ) {
+ playername[playername_length] = data[3+playername_length];
+ if (data[3+playername_length] == 0)
+ break;
+ }
+
+ if (playername_length == PLAYERNAME_SIZE) {
+ actionstream<<"Server: Player with name exceeding max length "
+ <<"tried to connect from "<<addr_s<<std::endl;
+ DenyAccess(peer_id, L"Name to long");
+ return;
}
- playername[PLAYERNAME_SIZE-1] = 0;
+
if(playername[0]=='\0')
{