From: bones_was_here Date: Thu, 18 Jan 2024 05:43:15 +0000 (+1000) Subject: PRVM: disallow changing read-only cvars X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1df5f9fe139f272669658a720bc9a3360a58789d;p=xonotic%2Fdarkplaces.git PRVM: disallow changing read-only cvars Signed-off-by: bones_was_here --- diff --git a/prvm_cmds.c b/prvm_cmds.c index 379b7d36..5a866222 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -806,12 +806,25 @@ void cvar_set (string,string, ...) void VM_cvar_set(prvm_prog_t *prog) { const char *name; - char string[VM_STRINGTEMP_LENGTH]; + char value[VM_STRINGTEMP_LENGTH]; + cvar_t *cvar; + VM_SAFEPARMCOUNTRANGE(2,8,VM_cvar_set); - VM_VarString(prog, 1, string, sizeof(string)); name = PRVM_G_STRING(OFS_PARM0); VM_CheckEmptyString(prog, name); - Cvar_Set(prog->console_cmd->cvars, name, string); + cvar = Cvar_FindVar(prog->console_cmd->cvars, name, prog->console_cmd->cvars_flagsmask); + if (!cvar) + { + VM_Warning(prog, "VM_cvar_set: variable %s not found\n", name); + return; + } + if (cvar->flags & CF_READONLY) + { + VM_Warning(prog, "VM_cvar_set: variable %s is read-only\n", cvar->name); + return; + } + VM_VarString(prog, 1, value, sizeof(value)); + Cvar_SetQuick(cvar, value); } /*