engine: client: carefully check legacy server response, check info string before passing it to UI
This commit is contained in:
parent
0d2552c3f6
commit
9d4fe707bb
1 changed files with 19 additions and 10 deletions
|
@ -1713,16 +1713,23 @@ void CL_ParseStatusMessage( netadr_t from, sizebuf_t *msg )
|
||||||
static char infostring[MAX_INFO_STRING+8];
|
static char infostring[MAX_INFO_STRING+8];
|
||||||
char *s = MSG_ReadString( msg );
|
char *s = MSG_ReadString( msg );
|
||||||
int i;
|
int i;
|
||||||
|
const char *magic = ": wrong version\n";
|
||||||
|
size_t len = Q_strlen( s ), magiclen = Q_strlen( magic );
|
||||||
|
|
||||||
CL_FixupColorStringsForInfoString( s, infostring );
|
if( len >= magiclen && !Q_strcmp( s + len - magiclen, magic ))
|
||||||
|
|
||||||
if( Q_strstr( infostring, "wrong version" ) )
|
|
||||||
{
|
{
|
||||||
Netchan_OutOfBandPrint( NS_CLIENT, from, "info %i", PROTOCOL_LEGACY_VERSION );
|
Netchan_OutOfBandPrint( NS_CLIENT, from, "info %i", PROTOCOL_LEGACY_VERSION );
|
||||||
Con_Printf( "^1Server^7: %s, Info: %s\n", NET_AdrToString( from ), infostring );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !Info_IsValid( s ))
|
||||||
|
{
|
||||||
|
Con_Printf( "^1Server^7: %s, invalid infostring\n", NET_AdrToString( from ));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CL_FixupColorStringsForInfoString( s, infostring );
|
||||||
|
|
||||||
if( !COM_CheckString( Info_ValueForKey( infostring, "gamedir" )))
|
if( !COM_CheckString( Info_ValueForKey( infostring, "gamedir" )))
|
||||||
{
|
{
|
||||||
Con_Printf( "^1Server^7: %s, Info: %s\n", NET_AdrToString( from ), infostring );
|
Con_Printf( "^1Server^7: %s, Info: %s\n", NET_AdrToString( from ), infostring );
|
||||||
|
@ -1732,11 +1739,13 @@ void CL_ParseStatusMessage( netadr_t from, sizebuf_t *msg )
|
||||||
if( !COM_CheckString( Info_ValueForKey( infostring, "p" )))
|
if( !COM_CheckString( Info_ValueForKey( infostring, "p" )))
|
||||||
{
|
{
|
||||||
Info_SetValueForKey( infostring, "legacy", "1", sizeof( infostring ) );
|
Info_SetValueForKey( infostring, "legacy", "1", sizeof( infostring ) );
|
||||||
Con_Print("Legacy: ");
|
Con_Printf( "^3Server^7: %s, Game: %s\n", NET_AdrToString( from ), Info_ValueForKey( infostring, "gamedir" ));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// more info about servers
|
// more info about servers
|
||||||
Con_Printf( "^2Server^7: %s, Game: %s\n", NET_AdrToString( from ), Info_ValueForKey( infostring, "gamedir" ));
|
Con_Printf( "^2Server^7: %s, Game: %s\n", NET_AdrToString( from ), Info_ValueForKey( infostring, "gamedir" ));
|
||||||
|
}
|
||||||
|
|
||||||
UI_AddServerToList( from, infostring );
|
UI_AddServerToList( from, infostring );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue