From a5802640d1ecf2b7b87f1dd861b0563665bd0df3 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Wed, 7 Sep 2011 19:38:19 +0000 Subject: Require gamename if not supporting legacy protocol. --- src/client/cl_main.c | 11 ++++++++++- src/server/sv_client.c | 23 +++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/client/cl_main.c b/src/client/cl_main.c index aee69445..58618f19 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -3819,13 +3819,22 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) { char *infoString; int prot; char *gamename; + qboolean gameMismatch; infoString = MSG_ReadString( msg ); // if this isn't the correct gamename, ignore it gamename = Info_ValueForKey( infoString, "gamename" ); - if (gamename && *gamename && strcmp(gamename, com_gamename->string)) +#ifdef LEGACY_PROTOCOL + // gamename is optional for legacy protocol + if (com_legacyprotocol->integer && !*gamename) + gameMismatch = qfalse; + else +#endif + gameMismatch = !*gamename || strcmp(gamename, com_gamename->string) != 0; + + if (gameMismatch) { Com_DPrintf( "Game mismatch in info packet: %s\n", infoString ); return; diff --git a/src/server/sv_client.c b/src/server/sv_client.c index f3d190de..93519177 100644 --- a/src/server/sv_client.c +++ b/src/server/sv_client.c @@ -61,17 +61,24 @@ void SV_GetChallenge(netadr_t from) challenge_t *challenge; qboolean wasfound = qfalse; char *gameName; + qboolean gameMismatch; gameName = Cmd_Argv(2); - if(gameName && *gameName) + +#ifdef LEGACY_PROTOCOL + // gamename is optional for legacy protocol + if (com_legacyprotocol->integer && !*gameName) + gameMismatch = qfalse; + else +#endif + gameMismatch = !*gameName || strcmp(gameName, com_gamename->string) != 0; + + // reject client if the gamename string sent by the client doesn't match ours + if (gameMismatch) { - // reject client if the heartbeat string sent by the client doesn't match ours - if(strcmp(gameName, com_gamename->string)) - { - NET_OutOfBandPrint(NS_SERVER, from, "print\nGame mismatch: This is a %s server\n", - com_gamename->string); - return; - } + NET_OutOfBandPrint(NS_SERVER, from, "print\nGame mismatch: This is a %s server\n", + com_gamename->string); + return; } oldest = 0; -- cgit