From 75b84f94015e7d203e69ae67f83c1ad4b27e56c8 Mon Sep 17 00:00:00 2001 From: lotodore Date: Wed, 12 Oct 2011 08:37:22 +0000 Subject: [PATCH] Fixing ticket #75: Game names are now trimmed, and it is verified that the first character is printable. --- src/net/common/serverlobbythread.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index 8a11a1a6..8f656991 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #define SERVER_MAX_NUM_LOBBY_SESSIONS 512 // Maximum number of idle users in lobby. @@ -1243,9 +1244,13 @@ ServerLobbyThread::HandleNetPacketCreateGame(boost::shared_ptr sess GameData tmpData; NetPacket::GetGameData(&newGame.gameInfo, tmpData); string gameName(STL_STRING_FROM_OCTET_STRING(newGame.gameInfo.gameName)); + // Always trim the game name. + boost::trim(gameName); unsigned gameId = GetNextGameId(); - if (IsGameNameInUse(gameName)) { + if (gameName.empty() || !isprint(gameName[0])) { + SendJoinGameFailed(session, gameId, NTF_NET_JOIN_GAME_BAD_NAME); + } else if (IsGameNameInUse(gameName)) { SendJoinGameFailed(session, gameId, NTF_NET_JOIN_GAME_NAME_IN_USE); } else if (GetBanManager().IsBadGameName(gameName)) { SendJoinGameFailed(session, gameId, NTF_NET_JOIN_GAME_BAD_NAME);