From 1fa9cec2ee4817e109c7359b2ee77108c299a2cd Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Sat, 3 Nov 2018 20:08:07 +0000 Subject: [PATCH] libc/mktemp: Pass flags to open() The flags from the functions that call _gettemp() are never used. They should be included in the call to open(), otherwise features like O_CLOEXEC don't work. aly: (1) Checked FreeBSD and it behaves the same way as this fix. (2) Improve the style a bit. --- lib/libc/stdio/mktemp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c index d186fd75f6..28d70021db 100644 --- a/lib/libc/stdio/mktemp.c +++ b/lib/libc/stdio/mktemp.c @@ -165,9 +165,10 @@ _gettemp(char *path, int *doopen, int domkdir, int slen, int oflags) for (;;) { if (doopen) { - if ((*doopen = - _open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0) + if ((*doopen = _open(path, O_CREAT|O_EXCL|O_RDWR|oflags, + 0600)) >= 0) { return (1); + } if (errno != EEXIST) return (0); } else if (domkdir) { -- 2.41.0