Browse Source

Fix fd leaks in mod_cgi (fds not closed on pipe/fork failures, found by Rodrigo, fixes #2158, #2159)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2706 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.26
Stefan Bühler 12 years ago
parent
commit
85b1f6afd3
  1. 6
      src/mod_cgi.c

6
src/mod_cgi.c

@ -747,6 +747,8 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer *
}
if (pipe(from_cgi_fds)) {
close(to_cgi_fds[0]);
close(to_cgi_fds[1]);
log_error_write(srv, __FILE__, __LINE__, "ss", "pipe failed:", strerror(errno));
return -1;
}
@ -1035,6 +1037,10 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer *
case -1:
/* error */
log_error_write(srv, __FILE__, __LINE__, "ss", "fork failed:", strerror(errno));
close(from_cgi_fds[0]);
close(from_cgi_fds[1]);
close(to_cgi_fds[0]);
close(to_cgi_fds[1]);
return -1;
break;
default: {

Loading…
Cancel
Save