aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Bühler <stbuehler@web.de>2014-06-03 11:17:46 +0000
committerStefan Bühler <stbuehler@web.de>2014-06-03 11:17:46 +0000
commitb6a989e6e4668fa9040484ac244033f587a57e89 (patch)
tree5f4ce416d65070e41a3894ce35a61c3868f7a4f3
parent190afc6de1235b3a9516ad592614d3a32292cb85 (diff)
downloadspawn-fcgi-b6a989e6e4668fa9040484ac244033f587a57e89.tar.gz
spawn-fcgi-b6a989e6e4668fa9040484ac244033f587a57e89.zip
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
-rw-r--r--NEWS1
-rw-r--r--src/spawn-fcgi.c6
2 files changed, 7 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 15f0485..c50359c 100644
--- a/NEWS
+++ b/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
diff --git a/src/spawn-fcgi.c b/src/spawn-fcgi.c
index 9cd80f8..8f89d13 100644
--- a/src/spawn-fcgi.c
+++ b/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 */