From: sapier Date: Fri, 22 Aug 2014 12:03:04 +0000 (+0200) Subject: Add player name length checks X-Git-Tag: 0.4.11~314 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=refs%2Fpull%2F1572%2Fhead;p=oweals%2Fminetest.git Add player name length checks --- diff --git a/src/main.cpp b/src/main.cpp index bb2ac5faf..a44a2e611 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -79,6 +79,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "httpfetch.h" #include "guiEngine.h" #include "mapsector.h" +#include "player.h" #include "database-sqlite3.h" #ifdef USE_LEVELDB @@ -1843,6 +1844,13 @@ int main(int argc, char *argv[]) break; } + if (current_playername.length() > PLAYERNAME_SIZE-1) { + error_message = wgettext("Player name to long."); + playername = current_playername.substr(0,PLAYERNAME_SIZE-1); + g_settings->set("name", playername); + continue; + } + /* Run game */ 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