diff options
author | Christopher Schwarz <lakitu7@gmail.com> | 2009-10-16 22:29:39 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:16:52 +0000 |
commit | d1abff28e40d86c34e93ddbf2af222ffe552f6b8 (patch) | |
tree | fe490e1da3949555a6eb5c9d74876f0746dde034 /src/ui | |
parent | 9a60b0c6c2252e95caa35e4b00b310b5e628371b (diff) |
* (bug 4303) Disallow blank hostnames and non-printing characters in the server browser (thanks Khalsa)
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/ui_main.c | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c index c88363ce..15699991 100644 --- a/src/ui/ui_main.c +++ b/src/ui/ui_main.c @@ -267,20 +267,53 @@ void UI_DrawRect( float x, float y, float width, float height, float size, const /* ================== +UI_ServerInfoIsValid + +Return false if the infostring contains nonprinting characters, + or if the hostname is blank/undefined +================== +*/ +static qboolean UI_ServerInfoIsValid( char *info ) +{ + char *c; + int len = 0; + + for( c = info; *c; c++ ) + { + if( !isprint( *c ) ) + return qfalse; + } + + for( c = Info_ValueForKey( info, "hostname" ); *c; c++ ) + { + if( isgraph( *c ) ) + len++; + } + + if( len ) + return qfalse; + else + return qtrue; +} + +/* +================== UI_InsertServerIntoDisplayList ================== */ static void UI_InsertServerIntoDisplayList( int num, int position ) { - int i; + int i; static char info[MAX_STRING_CHARS]; if( position < 0 || position > uiInfo.serverStatus.numDisplayServers ) return; - trap_LAN_GetServerInfo( ui_netSource.integer, num, info, MAX_STRING_CHARS ); + if( !UI_ServerInfoIsValid( info ) ) // don't list servers with invalid info + return; + uiInfo.serverStatus.numDisplayServers++; for( i = uiInfo.serverStatus.numDisplayServers; i > position; i-- ) @@ -968,7 +1001,8 @@ static void UI_StopServerRefresh( void ) if( count - uiInfo.serverStatus.numDisplayServers > 0 ) { - Com_Printf( "%d servers not listed due to packet loss or pings higher than %d\n", + Com_Printf( "%d servers not listed due to packet loss, invalid info," + " or pings higher than %d\n", count - uiInfo.serverStatus.numDisplayServers, ( int ) trap_Cvar_VariableValue( "cl_maxPing" ) ); } |