summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/tmpfile.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1998-03-10 20:27:06 +0000
committerderaadt <deraadt@openbsd.org>1998-03-10 20:27:06 +0000
commit6a5a85b7c7daea401d5a32ae276c883ca2f0b95e (patch)
tree5b49a5ee19d57a3e9d70b62d17d099a4cca21823 /lib/libc/stdio/tmpfile.c
parentumask manipulation not neccessary (diff)
downloadwireguard-openbsd-6a5a85b7c7daea401d5a32ae276c883ca2f0b95e.tar.xz
wireguard-openbsd-6a5a85b7c7daea401d5a32ae276c883ca2f0b95e.zip
fchown() after unlink(), taking umask into account; std conformance according to casper@HOLLAND.SUN.COM
Diffstat (limited to 'lib/libc/stdio/tmpfile.c')
-rw-r--r--lib/libc/stdio/tmpfile.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/libc/stdio/tmpfile.c b/lib/libc/stdio/tmpfile.c
index 265ed26b2d8..7496c504738 100644
--- a/lib/libc/stdio/tmpfile.c
+++ b/lib/libc/stdio/tmpfile.c
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: tmpfile.c,v 1.4 1997/04/03 05:31:38 millert Exp $";
+static char rcsid[] = "$OpenBSD: tmpfile.c,v 1.5 1998/03/10 20:27:06 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -62,8 +62,14 @@ tmpfile()
(void)sigprocmask(SIG_BLOCK, &set, &oset);
fd = mkstemp(buf);
- if (fd != -1)
+ if (fd != -1) {
+ mode_t u;
+
(void)unlink(buf);
+ u = umask(0);
+ (void)umask(u);
+ (void)fchmod(fd, 0666 & ~u);
+ }
(void)sigprocmask(SIG_SETMASK, &oset, NULL);