Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2-archivedmodifications
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
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Skydusk
SRB2-archivedmodifications
Commits
5579fb52
Commit
5579fb52
authored
9 years ago
by
wolfs
Browse files
Options
Downloads
Patches
Plain Diff
Limit file creation/manipulation to luafiles subfolder
Also block % in filename strings
parent
de03db99
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/blua/liolib.c
+7
-1
7 additions, 1 deletion
src/blua/liolib.c
with
7 additions
and
1 deletion
src/blua/liolib.c
+
7
−
1
View file @
5579fb52
...
@@ -17,6 +17,9 @@
...
@@ -17,6 +17,9 @@
#include
"lauxlib.h"
#include
"lauxlib.h"
#include
"lualib.h"
#include
"lualib.h"
#include
"../i_system.h"
#include
"../doomdef.h"
#include
"../m_misc.h"
...
@@ -173,11 +176,14 @@ static int io_open (lua_State *L) {
...
@@ -173,11 +176,14 @@ static int io_open (lua_State *L) {
}
}
}
}
if
(
strstr
(
filename
,
".."
)
||
strchr
(
filename
,
':'
)
||
StartsWith
(
filename
,
"
\\
"
)
if
(
strstr
(
filename
,
".."
)
||
strchr
(
filename
,
':'
)
||
StartsWith
(
filename
,
"
\\
"
)
||
StartsWith
(
filename
,
"/"
)
||
!
pass
)
||
StartsWith
(
filename
,
"/"
)
||
strchr
(
filename
,
'%'
)
||
!
pass
)
{
{
luaL_error
(
L
,
"access denied to %s"
,
filename
);
luaL_error
(
L
,
"access denied to %s"
,
filename
);
return
pushresult
(
L
,
0
,
filename
);
return
pushresult
(
L
,
0
,
filename
);
}
}
I_mkdir
(
"luafiles"
,
0755
);
char
*
destFilename
=
va
(
"luafiles"
PATHSEP
"%s"
,
filename
);
filename
=
destFilename
;
const
char
*
mode
=
luaL_optstring
(
L
,
2
,
"r"
);
const
char
*
mode
=
luaL_optstring
(
L
,
2
,
"r"
);
FILE
**
pf
=
newfile
(
L
);
FILE
**
pf
=
newfile
(
L
);
*
pf
=
fopen
(
filename
,
mode
);
*
pf
=
fopen
(
filename
,
mode
);
...
...
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