summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2014-10-26 20:38:14 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2014-10-26 20:38:14 +0000
commit9984f073bd5c5a6aaf05c67798036b12a4c09f6d (patch)
treee2c1c3528bf22b10ec5cb16b36f4c8bd3eda40a6 /usr.bin
parentd8508a468e716a887fc49618cdc5f69c0d315de5 (diff)
Prefer mkostemp(O_CLOEXEC) over mkstemp()+fcntl(F_SETFD)
Prefer fopen("re") over fopen("r")+fcntl(F_SETFD) ok otto@ millert@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/chpass/chpass.c6
-rw-r--r--usr.bin/mail/lex.c8
2 files changed, 6 insertions, 8 deletions
diff --git a/usr.bin/chpass/chpass.c b/usr.bin/chpass/chpass.c
index 24f2eebc6a8..8fed8c4190a 100644
--- a/usr.bin/chpass/chpass.c
+++ b/usr.bin/chpass/chpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: chpass.c,v 1.39 2013/04/18 16:23:25 okan Exp $ */
+/* $OpenBSD: chpass.c,v 1.40 2014/10/26 20:38:13 guenther Exp $ */
/* $NetBSD: chpass.c,v 1.8 1996/05/15 21:50:43 jtc Exp $ */
/*-
@@ -167,8 +167,8 @@ main(int argc, char *argv[])
if ((pw = pw_dup(pw)) == NULL)
pw_error(NULL, 1, 1);
- dfd = mkstemp(tempname);
- if (dfd == -1 || fcntl(dfd, F_SETFD, FD_CLOEXEC) == -1)
+ dfd = mkostemp(tempname, O_CLOEXEC);
+ if (dfd == -1)
pw_error(tempname, 1, 1);
display(tempname, dfd, pw);
edit_status = edit(tempname, pw);
diff --git a/usr.bin/mail/lex.c b/usr.bin/mail/lex.c
index a8739738bd3..d226929a752 100644
--- a/usr.bin/mail/lex.c
+++ b/usr.bin/mail/lex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lex.c,v 1.37 2014/05/20 01:25:23 guenther Exp $ */
+/* $OpenBSD: lex.c,v 1.38 2014/10/26 20:38:13 guenther Exp $ */
/* $NetBSD: lex.c,v 1.10 1997/05/17 19:55:13 pk Exp $ */
/*
@@ -124,13 +124,11 @@ setfile(char *name)
mailsize = fsize(ibuf);
(void)snprintf(tempname, sizeof(tempname),
"%s/mail.RxXXXXXXXXXX", tmpdir);
- if ((fd = mkstemp(tempname)) == -1 ||
+ if ((fd = mkostemp(tempname, O_CLOEXEC)) == -1 ||
(otf = fdopen(fd, "w")) == NULL)
err(1, "%s", tempname);
- (void)fcntl(fileno(otf), F_SETFD, FD_CLOEXEC);
- if ((itf = fopen(tempname, "r")) == NULL)
+ if ((itf = fopen(tempname, "re")) == NULL)
err(1, "%s", tempname);
- (void)fcntl(fileno(itf), F_SETFD, FD_CLOEXEC);
(void)rm(tempname);
setptr(ibuf, (off_t)0);
setmsize(msgCount);