Revert my recent cvar latch changes

My cvar latch system changes prevent the Game VM from changing
g_gametype when the value is out of range due to it being registed in
the engine. It's been pointed out as fragile method of security, which
was still exploitable, by Noah Metzger (Chomenor). It doesn't seem like
this is working out to be a good solution.

The issue of fs_game '..' on server being relicated on client via
systeminfo exploit is still fixed as it's not affected by latch.
There are a few cases from current values of fs_game are used which
ideally should use fs_gamedir char array which has been validated.

Revert "Don't let VMs change engine latch cvars immediately"
Partially revert "Fix fs_game '..' reading outside of home and base path"
Revert "Fix VMs forcing engine latch cvar to update to latched value"
This commit is contained in:
Zack Middleton 2018-01-21 22:09:42 -06:00
parent ed8d48cac3
commit 738465d677
4 changed files with 26 additions and 37 deletions

View file

@ -638,29 +638,18 @@ Cvar_SetSafe
void Cvar_SetSafe( const char *var_name, const char *value )
{
int flags = Cvar_Flags( var_name );
qboolean force = qtrue;
if ( flags != CVAR_NONEXISTENT )
if((flags != CVAR_NONEXISTENT) && (flags & CVAR_PROTECTED))
{
if ( flags & CVAR_PROTECTED )
{
if( value )
Com_Error( ERR_DROP, "Restricted source tried to set "
"\"%s\" to \"%s\"", var_name, value );
else
Com_Error( ERR_DROP, "Restricted source tried to "
"modify \"%s\"", var_name );
return;
}
// don't let VMs or server change engine latched cvars instantly
if ( ( flags & CVAR_LATCH ) && !( flags & CVAR_VM_CREATED ) )
{
force = qfalse;
}
if( value )
Com_Error( ERR_DROP, "Restricted source tried to set "
"\"%s\" to \"%s\"", var_name, value );
else
Com_Error( ERR_DROP, "Restricted source tried to "
"modify \"%s\"", var_name );
return;
}
Cvar_Set2 (var_name, value, force);
Cvar_Set( var_name, value );
}
/*
@ -1376,13 +1365,7 @@ void Cvar_Register(vmCvar_t *vmCvar, const char *varName, const char *defaultVal
if ( cv && ( cv->flags & CVAR_PROTECTED ) ) {
Com_DPrintf( S_COLOR_YELLOW "WARNING: VM tried to register protected cvar '%s' with value '%s'%s\n",
varName, defaultValue, ( flags & ~cv->flags ) != 0 ? " and new flags" : "" );
}
// Don't set engine latch cvar to latched value.
else if ( cv && ( cv->flags & CVAR_LATCH ) && !( cv->flags & CVAR_VM_CREATED ) ) {
cv->flags |= flags;
cvar_modifiedFlags |= flags;
}
else {
} else {
cv = Cvar_Get(varName, defaultValue, flags | CVAR_VM_CREATED);
}