Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
49f1462f
Commit
49f1462f
authored
2 years ago
by
James R.
Browse files
Options
Downloads
Patches
Plain Diff
Only let Lua run commands registered with COM_LUA
parent
8a6f2e56
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1943
Fix up Lua command/cvar safety
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/command.c
+7
-1
7 additions, 1 deletion
src/command.c
src/command.h
+2
-0
2 additions, 0 deletions
src/command.h
with
9 additions
and
1 deletion
src/command.c
+
7
−
1
View file @
49f1462f
...
...
@@ -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
;
}
...
...
This diff is collapsed.
Click to expand it.
src/command.h
+
2
−
0
View file @
49f1462f
...
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment