From: Lennart Poettering Date: Mon, 26 Feb 2018 19:51:04 +0000 (+0100) Subject: nspawn: close pipe on error X-Git-Tag: v238~37^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F8283%2Fhead;p=thirdparty%2Fsystemd.git nspawn: close pipe on error --- diff --git a/src/nspawn/nspawn-setuid.c b/src/nspawn/nspawn-setuid.c index c4ad1725122..46cdcd2e843 100644 --- a/src/nspawn/nspawn-setuid.c +++ b/src/nspawn/nspawn-setuid.c @@ -48,11 +48,13 @@ static int spawn_getent(const char *database, const char *key, pid_t *rpid) { return log_error_errno(errno, "Failed to allocate pipe: %m"); r = safe_fork("(getent)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid); - if (r < 0) + if (r < 0) { + safe_close_pair(pipe_fds); return r; + } if (r == 0) { - int nullfd; char *empty_env = NULL; + int nullfd; if (dup3(pipe_fds[1], STDOUT_FILENO, 0) < 0) _exit(EXIT_FAILURE);