Index: src/server/sv_client.c =================================================================== --- src/server/sv_client.c (revision 898) +++ src/server/sv_client.c (working copy) @@ -134,6 +134,17 @@ break; } } + + // r1: userinfo truncation and ip spoofing checks + if ( strlen (userinfo) > 990 ) { + NET_OutOfBandPrint( NS_SERVER, from, "print\nUserinfo string length exceeded" ); + return; + } + + if ( Info_ValueForKey ( userinfo, "ip" )[0] ) { + NET_OutOfBandPrint( NS_SERVER, from, "print\nIllegal key 'ip' in userinfo" ); + return; + } // see if the challenge is valid (LAN clients don't need to challenge) if ( !NET_IsLocalAddress (from) ) { @@ -1060,16 +1071,14 @@ // maintain the IP information // this is set in SV_DirectConnect (directly on the server, not transmitted), may be lost when client updates it's userinfo // the banning code relies on this being consistently present - val = Info_ValueForKey (cl->userinfo, "ip"); - if (!val[0]) - { - //Com_DPrintf("Maintain IP in userinfo for '%s'\n", cl->name); - if ( !NET_IsLocalAddress(cl->netchan.remoteAddress) ) - Info_SetValueForKey( cl->userinfo, "ip", NET_AdrToString( cl->netchan.remoteAddress ) ); - else - // force the "ip" info key to "localhost" for local clients - Info_SetValueForKey( cl->userinfo, "ip", "localhost" ); - } + + // r1: always force this, never trust the client + //Com_DPrintf("Maintain IP in userinfo for '%s'\n", cl->name); + if ( !NET_IsLocalAddress(cl->netchan.remoteAddress) ) + Info_SetValueForKey( cl->userinfo, "ip", NET_AdrToString( cl->netchan.remoteAddress ) ); + else + // force the "ip" info key to "localhost" for local clients + Info_SetValueForKey( cl->userinfo, "ip", "localhost" ); } @@ -1080,6 +1089,17 @@ */ static void SV_UpdateUserinfo_f( client_t *cl ) { Q_strncpyz( cl->userinfo, Cmd_Argv(1), sizeof(cl->userinfo) ); + + // r1: ip and userinfo truncation check + if ( strlen ( cl->userinfo ) > 990 ) { + SV_DropClient ( cl, "userinfo string length exceeded" ); + return; + } + + if ( Info_ValueForKey( cl->userinfo, "ip" )[0] ) { + SV_DropClient ( cl, "attempted to ip spoof" ); + return; + } SV_UserinfoChanged( cl ); // call prog code to allow overrides