mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-27 12:26:24 +00:00
Prevent possible assert fail on windows in handle_cgi_request()
This commit is contained in:
1 parent
0b942aaaba
commit
d883b0f0f9
1 file changed
+9
-7
+9
-7
@@ -3110,7 +3110,15 @@ static void handle_cgi_request(struct mg_connection *conn, const char *prog) {
|
||||
send_http_error(conn, 500, http_500_error,
|
||||
"Cannot spawn CGI process [%s]: %s", prog, strerror(ERRNO));
|
||||
goto done;
|
||||
} else if ((in = fdopen(fd_stdin[1], "wb")) == NULL ||
|
||||
}
|
||||
|
||||
// spawn_process() must close those!
|
||||
// If we don't mark them as closed, close() attempt before
|
||||
// return from this function throws an exception on Windows.
|
||||
// Windows does not like when closed descriptor is closed again.
|
||||
fd_stdin[0] = fd_stdout[1] = -1;
|
||||
|
||||
if ((in = fdopen(fd_stdin[1], "wb")) == NULL ||
|
||||
(out = fdopen(fd_stdout[0], "rb")) == NULL) {
|
||||
send_http_error(conn, 500, http_500_error,
|
||||
"fopen: %s", strerror(ERRNO));
|
||||
@@ -3120,12 +3128,6 @@ static void handle_cgi_request(struct mg_connection *conn, const char *prog) {
|
||||
setbuf(in, NULL);
|
||||
setbuf(out, NULL);
|
||||
|
||||
// spawn_process() must close those!
|
||||
// If we don't mark them as closed, close() attempt before
|
||||
// return from this function throws an exception on Windows.
|
||||
// Windows does not like when closed descriptor is closed again.
|
||||
fd_stdin[0] = fd_stdout[1] = -1;
|
||||
|
||||
// Send POST data to the CGI process if needed
|
||||
if (!strcmp(conn->request_info.request_method, "POST") &&
|
||||
!forward_body_data(conn, in, INVALID_SOCKET, NULL)) {
|
||||
|
||||
Reference in new issue
Block a user