summaryrefslogtreecommitdiffstats
path: root/usr.sbin/slowcgi
diff options
context:
space:
mode:
authorflorian <florian@openbsd.org>2013-10-21 18:19:27 +0000
committerflorian <florian@openbsd.org>2013-10-21 18:19:27 +0000
commite014c219de0d20a51ec51a3b74292fea9ce2e457 (patch)
treeb7b562793a56590f9c541f84ac650b51efb9093a /usr.sbin/slowcgi
parentCheck for EINTR, too. (diff)
downloadwireguard-openbsd-e014c219de0d20a51ec51a3b74292fea9ce2e457.tar.xz
wireguard-openbsd-e014c219de0d20a51ec51a3b74292fea9ce2e457.zip
Do not leak fds in fork(2) error path.
pointed out by deraadt@
Diffstat (limited to 'usr.sbin/slowcgi')
-rw-r--r--usr.sbin/slowcgi/slowcgi.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/usr.sbin/slowcgi/slowcgi.c b/usr.sbin/slowcgi/slowcgi.c
index a0c0aecdd8d..1a0b819c2dd 100644
--- a/usr.sbin/slowcgi/slowcgi.c
+++ b/usr.sbin/slowcgi/slowcgi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: slowcgi.c,v 1.22 2013/10/21 18:17:58 florian Exp $ */
+/* $OpenBSD: slowcgi.c,v 1.23 2013/10/21 18:19:27 florian Exp $ */
/*
* Copyright (c) 2013 David Gwynne <dlg@openbsd.org>
* Copyright (c) 2013 Florian Obser <florian@openbsd.org>
@@ -827,7 +827,23 @@ exec_cgi(struct request *c)
switch (pid = fork()) {
case -1:
+ c->script_status = errno;
+
lwarn("fork");
+
+ close(s_in[0]);
+ close(s_out[0]);
+ close(s_err[0]);
+
+ close(s_in[1]);
+ close(s_out[1]);
+ close(s_err[1]);
+
+ c->stdin_fd_closed = c->stdout_fd_closed =
+ c->stderr_fd_closed = 1;
+ c->script_flags = (STDOUT_DONE | STDERR_DONE | SCRIPT_DONE);
+
+ create_end_record(c);
return;
case 0:
/* Child process */