Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
mongoose
Commits
fd067c80
Commit
fd067c80
authored
Sep 23, 2016
by
Alexander Alashkin
Committed by
Cesanta Bot
Sep 23, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handles leak in CGI
PUBLISHED_FROM=6052b7bfec6af33328cbe369da60e9672ebac437
parent
04012760
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
mongoose.c
mongoose.c
+14
-14
No files found.
mongoose.c
View file @
fd067c80
...
@@ -6676,9 +6676,9 @@ static void mg_abs_path(const char *utf8_path, char *abs_path, size_t len) {
...
@@ -6676,9 +6676,9 @@ static void mg_abs_path(const char *utf8_path, char *abs_path, size_t len) {
WideCharToMultiByte
(
CP_UTF8
,
0
,
buf2
,
wcslen
(
buf2
)
+
1
,
abs_path
,
len
,
0
,
0
);
WideCharToMultiByte
(
CP_UTF8
,
0
,
buf2
,
wcslen
(
buf2
)
+
1
,
abs_path
,
len
,
0
,
0
);
}
}
static
pid_
t
mg_start_process
(
const
char
*
interp
,
const
char
*
cmd
,
static
in
t
mg_start_process
(
const
char
*
interp
,
const
char
*
cmd
,
const
char
*
env
,
const
char
*
envp
[],
const
char
*
env
,
const
char
*
envp
[],
const
char
*
dir
,
sock_t
sock
)
{
const
char
*
dir
,
sock_t
sock
)
{
STARTUPINFOW
si
;
STARTUPINFOW
si
;
PROCESS_INFORMATION
pi
;
PROCESS_INFORMATION
pi
;
HANDLE
a
[
2
],
b
[
2
],
me
=
GetCurrentProcess
();
HANDLE
a
[
2
],
b
[
2
],
me
=
GetCurrentProcess
();
...
@@ -6733,6 +6733,12 @@ static pid_t mg_start_process(const char *interp, const char *cmd,
...
@@ -6733,6 +6733,12 @@ static pid_t mg_start_process(const char *interp, const char *cmd,
(
void
*
)
env
,
full_dir
,
&
si
,
&
pi
)
!=
0
)
{
(
void
*
)
env
,
full_dir
,
&
si
,
&
pi
)
!=
0
)
{
mg_spawn_stdio_thread
(
sock
,
a
[
1
],
mg_push_to_stdin
);
mg_spawn_stdio_thread
(
sock
,
a
[
1
],
mg_push_to_stdin
);
mg_spawn_stdio_thread
(
sock
,
b
[
0
],
mg_pull_from_stdout
);
mg_spawn_stdio_thread
(
sock
,
b
[
0
],
mg_pull_from_stdout
);
CloseHandle
(
si
.
hStdOutput
);
CloseHandle
(
si
.
hStdInput
);
CloseHandle
(
pi
.
hThread
);
CloseHandle
(
pi
.
hProcess
);
}
else
{
}
else
{
CloseHandle
(
a
[
1
]);
CloseHandle
(
a
[
1
]);
CloseHandle
(
b
[
0
]);
CloseHandle
(
b
[
0
]);
...
@@ -6741,19 +6747,13 @@ static pid_t mg_start_process(const char *interp, const char *cmd,
...
@@ -6741,19 +6747,13 @@ static pid_t mg_start_process(const char *interp, const char *cmd,
DBG
((
"CGI command: [%ls] -> %p"
,
wcmd
,
pi
.
hProcess
));
DBG
((
"CGI command: [%ls] -> %p"
,
wcmd
,
pi
.
hProcess
));
/* Not closing a[0] and b[1] because we've used DUPLICATE_CLOSE_SOURCE */
/* Not closing a[0] and b[1] because we've used DUPLICATE_CLOSE_SOURCE */
CloseHandle
(
si
.
hStdOutput
);
CloseHandle
(
si
.
hStdInput
);
/* TODO(lsm): check if we need close process and thread handles too */
/* CloseHandle(pi.hThread); */
/* CloseHandle(pi.hProcess); */
(
void
)
envp
;
(
void
)
envp
;
return
pi
.
hProcess
;
return
(
pi
.
hProcess
!=
NULL
)
;
}
}
#else
#else
static
pid_
t
mg_start_process
(
const
char
*
interp
,
const
char
*
cmd
,
static
in
t
mg_start_process
(
const
char
*
interp
,
const
char
*
cmd
,
const
char
*
env
,
const
char
*
envp
[],
const
char
*
env
,
const
char
*
envp
[],
const
char
*
dir
,
sock_t
sock
)
{
const
char
*
dir
,
sock_t
sock
)
{
char
buf
[
500
];
char
buf
[
500
];
pid_t
pid
=
fork
();
pid_t
pid
=
fork
();
(
void
)
env
;
(
void
)
env
;
...
@@ -6791,7 +6791,7 @@ static pid_t mg_start_process(const char *interp, const char *cmd,
...
@@ -6791,7 +6791,7 @@ static pid_t mg_start_process(const char *interp, const char *cmd,
exit
(
EXIT_FAILURE
);
/* exec call failed */
exit
(
EXIT_FAILURE
);
/* exec call failed */
}
}
return
pid
;
return
(
pid
!=
0
)
;
}
}
#endif
/* _WIN32 */
#endif
/* _WIN32 */
...
...
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