Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
a49c688d
Commit
a49c688d
authored
Aug 24, 2011
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed directory traversal security issue for windows
parent
ba714de0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
mongoose.c
mongoose.c
+11
-4
No files found.
mongoose.c
View file @
a49c688d
...
@@ -889,7 +889,7 @@ static void change_slashes_to_backslashes(char *path) {
...
@@ -889,7 +889,7 @@ static void change_slashes_to_backslashes(char *path) {
// Encode 'path' which is assumed UTF-8 string, into UNICODE string.
// Encode 'path' which is assumed UTF-8 string, into UNICODE string.
// wbuf and wbuf_len is a target buffer and its length.
// wbuf and wbuf_len is a target buffer and its length.
static
void
to_unicode
(
const
char
*
path
,
wchar_t
*
wbuf
,
size_t
wbuf_len
)
{
static
void
to_unicode
(
const
char
*
path
,
wchar_t
*
wbuf
,
size_t
wbuf_len
)
{
char
buf
[
PATH_MAX
],
*
p
;
char
buf
[
PATH_MAX
],
buf2
[
PATH_MAX
],
*
p
;
mg_strlcpy
(
buf
,
path
,
sizeof
(
buf
));
mg_strlcpy
(
buf
,
path
,
sizeof
(
buf
));
change_slashes_to_backslashes
(
buf
);
change_slashes_to_backslashes
(
buf
);
...
@@ -911,10 +911,17 @@ static void to_unicode(const char *path, wchar_t *wbuf, size_t wbuf_len) {
...
@@ -911,10 +911,17 @@ static void to_unicode(const char *path, wchar_t *wbuf, size_t wbuf_len) {
*
p
==
0x2b
||
// No '+'
*
p
==
0x2b
||
// No '+'
(
*
p
&
~
0x7f
))
{
// And generally no non-ascii chars
(
*
p
&
~
0x7f
))
{
// And generally no non-ascii chars
(
void
)
fprintf
(
stderr
,
"Rejecting suspicious path: [%s]"
,
buf
);
(
void
)
fprintf
(
stderr
,
"Rejecting suspicious path: [%s]"
,
buf
);
buf
[
0
]
=
'\0'
;
wbuf
[
0
]
=
L'\0'
;
}
else
{
// Convert to Unicode and back. If doubly-converted string does not
// match the original, something is fishy, reject.
MultiByteToWideChar
(
CP_UTF8
,
0
,
buf
,
-
1
,
wbuf
,
(
int
)
wbuf_len
);
WideCharToMultiByte
(
CP_UTF8
,
0
,
wbuf
,
(
int
)
wbuf_len
,
buf2
,
sizeof
(
buf2
),
NULL
,
NULL
);
if
(
strcmp
(
buf
,
buf2
)
!=
0
)
{
wbuf
[
0
]
=
L'\0'
;
}
}
}
(
void
)
MultiByteToWideChar
(
CP_UTF8
,
0
,
buf
,
-
1
,
wbuf
,
(
int
)
wbuf_len
);
}
}
#if defined(_WIN32_WCE)
#if defined(_WIN32_WCE)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment