Browse Source

Fix resource leaks in failure cases (found with coverity)

From: Stefan Bühler <stbuehler@web.de>

git-svn-id: svn://svn.lighttpd.net/spawn-fcgi/trunk@69 4a9f3682-ca7b-49a8-9a55-ba4640e46f83
master
Stefan Bühler 7 years ago
parent
commit
b6a989e6e4
  1. 1
      NEWS
  2. 6
      src/spawn-fcgi.c

1
NEWS

@ -12,6 +12,7 @@ NEWS
* Add more flags to extra-warning flags
* Check return values of setuid, setgid, setgroups, initgroups, write
* Check whether compiler supports wanted CFLAGS (fixes #2235)
* Fix resource leaks in failure cases (found with coverity)
- 1.6.3 - 2009-09-23
* Fix unix socket mode change to work without specifying user/group for socket

6
src/spawn-fcgi.c

@ -185,11 +185,13 @@ static int bind_socket(const char *addr, unsigned short port, const char *unixso
val = 1;
if (setsockopt(fcgi_fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0) {
fprintf(stderr, "spawn-fcgi: couldn't set SO_REUSEADDR: %s\n", strerror(errno));
close(fcgi_fd);
return -1;
}
if (-1 == bind(fcgi_fd, fcgi_addr, servlen)) {
fprintf(stderr, "spawn-fcgi: bind failed: %s\n", strerror(errno));
close(fcgi_fd);
return -1;
}
@ -215,6 +217,8 @@ static int bind_socket(const char *addr, unsigned short port, const char *unixso
if (-1 == listen(fcgi_fd, backlog)) {
fprintf(stderr, "spawn-fcgi: listen failed: %s\n", strerror(errno));
close(fcgi_fd);
if (unixsocket) unlink(unixsocket);
return -1;
}
@ -283,6 +287,8 @@ static int fcgi_spawn_connection(char *appPath, char **appArgv, int fcgi_fd, int
/* exec the cgi */
execl("/bin/sh", "sh", "-c", b, (char *)NULL);
free(b);
}
/* in nofork mode stderr is still open */

Loading…
Cancel
Save