From: Joel Rosdahl Date: Sat, 5 Jan 2013 15:47:04 +0000 (+0100) Subject: Don't leak log file descriptor to executed commands X-Git-Tag: v3.1.9~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b6a109779033ffbb8ddab7cca6574f24c2e4bfb;p=thirdparty%2Fccache.git Don't leak log file descriptor to executed commands --- diff --git a/util.c b/util.c index 66be67d73..3b472def2 100644 --- a/util.c +++ b/util.c @@ -48,6 +48,11 @@ init_log(void) } logfile = fopen(cache_logfile, "a"); if (logfile) { + int fd = fileno(logfile); + int flags = fcntl(fd, F_GETFD, 0); + if (flags >= 0) { + fcntl(fd, F_SETFD, flags | FD_CLOEXEC); + } return true; } else { return false;