Skip to content
Snippets Groups Projects
Commit 49f1462f authored by James R.'s avatar James R.
Browse files

Only let Lua run commands registered with COM_LUA

parent 8a6f2e56
Branches
Tags
1 merge request!1943Fix up Lua command/cvar safety
......@@ -544,7 +544,7 @@ int COM_AddLuaCommand(const char *name)
cmd = ZZ_Alloc(sizeof *cmd);
cmd->name = name;
cmd->function = COM_Lua_f;
cmd->flags = 0;
cmd->flags = COM_LUA;
cmd->next = com_commands;
com_commands = cmd;
return 0;
......@@ -640,6 +640,12 @@ static void COM_ExecuteString(char *ptext)
{
if (!stricmp(com_argv[0], cmd->name)) //case insensitive now that we have lower and uppercase!
{
if ((com_flags & COM_LUA) && !(cmd->flags & COM_LUA))
{
CONS_Alert(CONS_WARNING, "Command '%s' cannot be run from Lua.\n", cmd->name);
return;
}
cmd->function();
return;
}
......
......@@ -29,6 +29,8 @@ typedef enum
// COM_BufInsertText etc: can only access cvars
// with CV_ALLOWLUA set.
// COM_AddCommand: without this flag, the command
// CANNOT be run from Lua.
COM_LUA = 8,
} com_flags_t;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment