void CL_ParseSetGame( msg_t *msg ) { char newGameDir[MAX_QPATH]; int i = 0; char next; while (i < MAX_QPATH) { next = MSG_ReadByte( msg ); if (next) { //if next is 0 then we have finished reading to the end of the message newGameDir[i] = next; } else { break; } i++; } newGameDir[i] = 0; if(FS_CheckDirTraversal(newGameDir)) { Com_Printf(S_COLOR_YELLOW "WARNING: Server sent invalid fs_game value %s\n", newGameDir); return; } Cvar_Set("fs_game", newGameDir); //Update the search path for the mod dir FS_UpdateGamedir(); }
void CL_ParseSetGame( msg_t *msg ) { char newGameDir[MAX_QPATH]; int i = 0; char next; while (i < MAX_QPATH) { next = MSG_ReadByte( msg ); if (next) { //if next is 0 then we have finished reading to the end of the message newGameDir[i] = next; } else { break; } i++; } newGameDir[i] = 0; if(FS_CheckDirTraversal(newGameDir)) { Com_Printf(S_COLOR_YELLOW "WARNING: Server sent invalid fs_game value %s\n", newGameDir); return; } if(!FS_FilenameCompare(newGameDir, BASEGAME)) Cvar_Set("fs_game", ""); else Cvar_Set("fs_game", newGameDir); if(!(Cvar_Flags("fs_game") & CVAR_MODIFIED)) return; //Update the search path for the mod dir FS_UpdateGamedir(); //Now update the overrides manually MSG_CheckNETFPSFOverrides(qfalse); MSG_CheckNETFPSFOverrides(qtrue); }
/* ================== CL_SystemInfoChanged The systeminfo configstring has been changed, so parse new information out of it. This will happen at every gamestate, and possibly during gameplay. ================== */ void CL_SystemInfoChanged( void ) { char *systemInfo; const char *s, *t; char key[BIG_INFO_KEY]; char value[BIG_INFO_VALUE]; qboolean gameSet; systemInfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SYSTEMINFO ]; // NOTE TTimo: // when the serverId changes, any further messages we send to the server will use this new serverId // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=475 // in some cases, outdated cp commands might get sent with this news serverId cl.serverId = atoi( Info_ValueForKey( systemInfo, "sv_serverid" ) ); #ifdef USE_VOIP s = Info_ValueForKey( systemInfo, "sv_voipProtocol" ); clc.voipEnabled = !Q_stricmp(s, "opus"); #endif // don't set any vars when playing a demo if ( clc.demoplaying ) { return; } s = Info_ValueForKey( systemInfo, "sv_cheats" ); cl_connectedToCheatServer = atoi( s ); if ( !cl_connectedToCheatServer ) { Cvar_SetCheatState(); } // check pure server string s = Info_ValueForKey( systemInfo, "sv_paks" ); t = Info_ValueForKey( systemInfo, "sv_pakNames" ); FS_PureServerSetLoadedPaks( s, t ); s = Info_ValueForKey( systemInfo, "sv_referencedPaks" ); t = Info_ValueForKey( systemInfo, "sv_referencedPakNames" ); FS_PureServerSetReferencedPaks( s, t ); gameSet = qfalse; // scan through all the variables in the systeminfo and locally set cvars to match s = systemInfo; while ( s ) { int cvar_flags; Info_NextPair( &s, key, value ); if ( !key[0] ) { break; } // ehw! if (!Q_stricmp(key, "fs_game")) { if(FS_CheckDirTraversal(value)) { Com_Printf(S_COLOR_YELLOW "WARNING: Server sent invalid fs_game value %s\n", value); continue; } gameSet = qtrue; } if((cvar_flags = Cvar_Flags(key)) == CVAR_NONEXISTENT) Cvar_Get(key, value, CVAR_SERVER_CREATED | CVAR_ROM); else { // If this cvar may not be modified by a server discard the value. if(!(cvar_flags & (CVAR_SYSTEMINFO | CVAR_SERVER_CREATED | CVAR_USER_CREATED))) { #ifndef STANDALONE if(Q_stricmp(key, "g_synchronousClients") && Q_stricmp(key, "pmove_fixed") && Q_stricmp(key, "pmove_msec")) #endif { Com_Printf(S_COLOR_YELLOW "WARNING: server is not allowed to set %s=%s\n", key, value); continue; } } Cvar_SetSafe(key, value); } } // if game folder should not be set and it is set at the client side if ( !gameSet && *Cvar_VariableString("fs_game") ) { Cvar_Set( "fs_game", "" ); } cl_connectedToPureServer = Cvar_VariableValue( "sv_pure" ); }
/* ================== CL_SystemInfoChanged The systeminfo configstring has been changed, so parse new information out of it. This will happen at every gamestate, and possibly during gameplay. ================== */ void CL_SystemInfoChanged( void ) { char *systemInfo; const char *s, *t; char key[BIG_INFO_KEY]; char value[BIG_INFO_VALUE]; qboolean gameSet; systemInfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SYSTEMINFO ]; // NOTE TTimo: // when the serverId changes, any further messages we send to the server will use this new serverId // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=475 // in some cases, outdated cp commands might get sent with this new serverId cl.serverId = atoi( Info_ValueForKey( systemInfo, "sv_serverid" ) ); // don't set any vars when playing a demo if ( clc.demoplaying ) { return; } s = Info_ValueForKey( systemInfo, "sv_cheats" ); cl_connectedToCheatServer = atoi( s ); if ( !cl_connectedToCheatServer ) { Cvar_SetCheatState(); } // check pure server string s = Info_ValueForKey( systemInfo, "sv_paks" ); t = Info_ValueForKey( systemInfo, "sv_pakNames" ); FS_PureServerSetLoadedPaks( s, t ); s = Info_ValueForKey( systemInfo, "sv_referencedPaks" ); t = Info_ValueForKey( systemInfo, "sv_referencedPakNames" ); FS_PureServerSetReferencedPaks( s, t ); gameSet = qfalse; // scan through all the variables in the systeminfo and locally set cvars to match s = systemInfo; while ( s ) { Info_NextPair( &s, key, value ); if ( !key[0] ) { break; } // ehw! if ( !Q_stricmp( key, "fs_game" ) ) { if(FS_CheckDirTraversal(value)) { Com_Printf(S_COLOR_YELLOW "WARNING: Server sent invalid fs_game value %s\n", value); continue; } if(!FS_FilenameCompare(value, BASEGAME)) { Com_Printf(S_COLOR_YELLOW "WARNING: Server sent \"%s\" fs_game value, clearing.\n", value); Q_strncpyz(value, "", sizeof(value)); } gameSet = qtrue; } Cvar_Server_Set( key, value ); } // if game folder should not be set and it is set at the client side if ( !gameSet && *Cvar_VariableString("fs_game") ) { Cvar_Set( "fs_game", "" ); } cl_connectedToPureServer = Cvar_VariableValue( "sv_pure" ); }
void CL_SystemInfoChanged(void) { char *systemInfo = cl.gameState.stringData + cl.gameState.stringOffsets[CS_SYSTEMINFO]; const char *s, *t; char key[BIG_INFO_KEY]; char value[BIG_INFO_VALUE]; qboolean gameSet; // NOTE: when the serverId changes, any further messages we send to the server will use this new serverId // in some cases, outdated cp commands might get sent with this news serverId cl.serverId = atoi(Info_ValueForKey(systemInfo, "sv_serverid")); memset(&entLastVisible, 0, sizeof(entLastVisible)); // don't set any vars when playing a demo if (clc.demoplaying) { return; } s = Info_ValueForKey(systemInfo, "sv_cheats"); cl_connectedToCheatServer = atoi(s); //bani if (!cl_connectedToCheatServer) { Cvar_SetCheatState(); } // check pure server string s = Info_ValueForKey(systemInfo, "sv_paks"); t = Info_ValueForKey(systemInfo, "sv_pakNames"); FS_PureServerSetLoadedPaks(s, t); s = Info_ValueForKey(systemInfo, "sv_referencedPaks"); t = Info_ValueForKey(systemInfo, "sv_referencedPakNames"); FS_PureServerSetReferencedPaks(s, t); gameSet = qfalse; // scan through all the variables in the systeminfo and locally set cvars to match s = systemInfo; while (s) { int cvar_flags; Info_NextPair(&s, key, value); if (!key[0]) { break; } // ehw! if (!Q_stricmp(key, "fs_game")) { if (FS_CheckDirTraversal(value)) { Com_Printf(S_COLOR_YELLOW "WARNING: Server sent invalid fs_game value %s\n", value); continue; } gameSet = qtrue; } if ((cvar_flags = Cvar_Flags(key)) == CVAR_NONEXISTENT) { Cvar_Get(key, value, CVAR_SERVER_CREATED | CVAR_ROM); } else { // If this cvar may not be modified by a server discard the value. if (!(cvar_flags & (CVAR_SYSTEMINFO | CVAR_SERVER_CREATED | CVAR_USER_CREATED))) { if (Q_stricmp(key, "g_synchronousClients") && Q_stricmp(key, "pmove_fixed") && Q_stricmp(key, "pmove_msec")) { Com_DPrintf(S_COLOR_YELLOW "WARNING: server is not allowed to set %s=%s\n", key, value); continue; } } Cvar_SetSafe(key, value); } } // if game folder should not be set and it is set at the client side if (!gameSet && *Cvar_VariableString("fs_game")) { Cvar_Set("fs_game", ""); } // big hack to clear the image cache on a pure change //cl_connectedToPureServer = Cvar_VariableValue( "sv_pure" ); if (Cvar_VariableValue("sv_pure")) { if (!cl_connectedToPureServer && cls.state <= CA_CONNECTED) { CL_PurgeCache(); } cl_connectedToPureServer = qtrue; } else { if (cl_connectedToPureServer && cls.state <= CA_CONNECTED) { CL_PurgeCache(); } cl_connectedToPureServer = qfalse; } }
void CL_SystemInfoChanged() { const char *s, *t; // don't set any vars when playing a demo if ( clc.demoplaying ) { return; } const char* systemInfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SYSTEMINFO ]; // when the serverId changes, any further messages we send to the server will use this new serverId // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=475 // in some cases, outdated cp commands might get sent with this new serverId cl.serverId = atoi( Info_ValueForKey( systemInfo, "sv_serverid" ) ); s = Info_ValueForKey( systemInfo, "sv_cheats" ); if ( atoi(s) == 0 ) { Cvar_SetCheatState(); } // check pure server string s = Info_ValueForKey( systemInfo, "sv_paks" ); t = Info_ValueForKey( systemInfo, "sv_pakNames" ); FS_PureServerSetLoadedPaks( s, t ); s = Info_ValueForKey( systemInfo, "sv_referencedPaks" ); t = Info_ValueForKey( systemInfo, "sv_referencedPakNames" ); FS_PureServerSetReferencedPaks( s, t ); qbool gameSet = qfalse; // scan through all the variables in the systeminfo and locally set cvars to match s = systemInfo; while ( s ) { char key[BIG_INFO_KEY], value[BIG_INFO_VALUE]; Info_NextPair( &s, key, value ); if ( !key[0] ) { break; } // ehw! if (!Q_stricmp(key, "fs_game")) { if (FS_CheckDirTraversal(value)) { Com_Printf("WARNING: Server sent invalid fs_game value %s\n", value); continue; } gameSet = qtrue; } // servers are only allowed to modify specific sets of cvars int flags = Cvar_Flags(key); if (flags == CVAR_NONEXISTENT) { Cvar_Get( key, value, CVAR_SERVER_CREATED | CVAR_ROM ); } else if (flags & (CVAR_SYSTEMINFO | CVAR_SERVER_CREATED)) { Cvar_Set( key, value ); } } // if game folder should not be set and it is set at the client side if ( !gameSet && *Cvar_VariableString("fs_game") ) { Cvar_Set( "fs_game", "" ); } cl_connectedToPureServer = Cvar_VariableValue( "sv_pure" ); }
/* ================== CL_SystemInfoChanged The systeminfo configstring has been changed, so parse new information out of it. This will happen at every gamestate, and possibly during gameplay. ================== */ void CL_SystemInfoChanged( void ) { char *systemInfo; const char *s, *t; char key[BIG_INFO_KEY]; char value[BIG_INFO_VALUE]; qboolean gameSet; systemInfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SYSTEMINFO ]; // NOTE TTimo: // when the serverId changes, any further messages we send to the server will use this new serverId // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=475 // in some cases, outdated cp commands might get sent with this news serverId cl.serverId = atoi( Info_ValueForKey( systemInfo, "sv_serverid" ) ); #ifdef USE_VOIP s = Info_ValueForKey( systemInfo, "sv_voipProtocol" ); clc.voipEnabled = !Q_stricmp(s, "opus"); #endif // don't set any vars when playing a demo if ( clc.demoplaying ) { return; } s = Info_ValueForKey( systemInfo, "sv_cheats" ); cl_connectedToCheatServer = atoi( s ); if ( !cl_connectedToCheatServer ) { Cvar_SetCheatState(); } // check pure server string s = Info_ValueForKey( systemInfo, "sv_paks" ); t = Info_ValueForKey( systemInfo, "sv_pakNames" ); FS_PureServerSetLoadedPaks( s, t ); s = Info_ValueForKey( systemInfo, "sv_referencedPaks" ); t = Info_ValueForKey( systemInfo, "sv_referencedPakNames" ); FS_PureServerSetReferencedPaks( s, t ); gameSet = qfalse; // scan through all the variables in the systeminfo and locally set cvars to match s = systemInfo; while ( s ) { Info_NextPair( &s, key, value ); if ( !key[0] ) { break; } // ehw! if (!Q_stricmp(key, "fs_game")) { char filename[MAX_QPATH]; char *title; if ( gameSet ) continue; if(FS_CheckDirTraversal(value)) { Com_Printf(S_COLOR_YELLOW "WARNING: Server sent invalid fs_game value %s\n", value); continue; } // create game title file if does not exist title = Info_ValueForKey( systemInfo, "sv_gameTitle" ); Com_sprintf( filename, sizeof ( filename ), "%s/description.txt", value ); if ( ( cl_allowDownload->integer & DLF_ENABLE ) && *title && !FS_SV_RW_FileExists( filename ) ) { fileHandle_t f = FS_SV_FOpenFileWrite( filename ); FS_Write( s, strlen( title ), f ); FS_FCloseFile( f ); } gameSet = qtrue; } Cvar_Server_Set(key, value); } // game folder must be set if ( !gameSet ) { Com_Error( ERR_DROP, "fs_game not set on server" ); } }