diff options
author | florian | 2013-10-21 18:19:27 +0000 |
---|---|---|
committer | Wynn Wolf Arbor | 2020-05-24 12:33:55 +0200 |
commit | 709e7f6d4fbca1018ba06b1e2259cc708a4c9cee (patch) | |
tree | 4b91dea9800af4a72c5d6a0cb06e91adce367716 /slowcgi.c | |
parent | 2ecbfa371fdab5e5b5dbeb1481ca05a0c9ce19fc (diff) | |
download | slowcgi-709e7f6d4fbca1018ba06b1e2259cc708a4c9cee.tar.gz |
Do not leak fds in fork(2) error path. pointed out by deraadt@
Diffstat (limited to '')
-rw-r--r-- | slowcgi.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -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 */ |