From 18cbc1e37047f2fabf61e32a4bc2997125ad21b4 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 5 Jul 2021 18:31:04 -0700 Subject: [PATCH 1/2] Fix aliases bypass COM_SAFE --- src/command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command.c b/src/command.c index 95b1fd67d..0e0b1a685 100644 --- a/src/command.c +++ b/src/command.c @@ -650,7 +650,7 @@ static void COM_ExecuteString(char *ptext) else { // Monster Iestyn: keep track of how many levels of recursion we're in recursion++; - COM_BufInsertText(a->value); + COM_BufInsertTextEx(a->value, com_flags); recursion--; } return; From 14c5d2c916e42c926dcf8267df3b49bd3dcab31d Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 5 Jul 2021 18:39:12 -0700 Subject: [PATCH 2/2] Warn if Lua attempted access NOLUA consvar And quote variable name. --- src/command.c | 5 ++++- src/lua_consolelib.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/command.c b/src/command.c index 0e0b1a685..e6c6587e8 100644 --- a/src/command.c +++ b/src/command.c @@ -2364,7 +2364,10 @@ static boolean CV_Command(void) return false; if (( com_flags & COM_SAFE ) && ( v->flags & CV_NOLUA )) - return false; + { + CONS_Alert(CONS_WARNING, "Variable '%s' cannot be changed from Lua.\n", v->name); + return true; + } // perform a variable print or set if (COM_Argc() == 1) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 414d9692a..2b8cad69b 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -433,7 +433,7 @@ static int CVarSetFunction consvar_t *cvar = *(consvar_t **)luaL_checkudata(L, 1, META_CVAR); if (cvar->flags & CV_NOLUA) - return luaL_error(L, "Variable %s cannot be set from Lua.", cvar->name); + return luaL_error(L, "Variable '%s' cannot be set from Lua.", cvar->name); switch (lua_type(L, 2)) {