Module Name:    src
Committed By:   christos
Date:           Thu Nov  9 20:27:50 UTC 2017

Modified Files:
        src/usr.bin/mail: cmd2.c cmd3.c collect.c edit.c fio.c lex.c list.c
            mime_attach.c mime_child.c mime_detach.c names.c quit.c send.c
            support.c

Log Message:
Only open regular files.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/mail/cmd2.c
cvs rdiff -u -r1.43 -r1.44 src/usr.bin/mail/cmd3.c src/usr.bin/mail/lex.c
cvs rdiff -u -r1.48 -r1.49 src/usr.bin/mail/collect.c
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/mail/edit.c src/usr.bin/mail/quit.c
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/mail/fio.c
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/mail/list.c
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/mail/mime_attach.c
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/mail/mime_child.c \
    src/usr.bin/mail/mime_detach.c
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/mail/names.c
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/mail/send.c
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/mail/support.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/mail/cmd2.c
diff -u src/usr.bin/mail/cmd2.c:1.25 src/usr.bin/mail/cmd2.c:1.26
--- src/usr.bin/mail/cmd2.c:1.25	Sun Apr 29 19:50:22 2012
+++ src/usr.bin/mail/cmd2.c	Thu Nov  9 15:27:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cmd2.c,v 1.25 2012/04/29 23:50:22 christos Exp $	*/
+/*	$NetBSD: cmd2.c,v 1.26 2017/11/09 20:27:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)cmd2.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: cmd2.c,v 1.25 2012/04/29 23:50:22 christos Exp $");
+__RCSID("$NetBSD: cmd2.c,v 1.26 2017/11/09 20:27:50 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -230,7 +230,7 @@ save1(char str[], int markmsg, const cha
 		disp = "[Appended]";
 	else
 		disp = "[New file]";
-	if ((obuf = Fopen(fn, "ae")) == NULL) {
+	if ((obuf = Fopen(fn, "aef")) == NULL) {
 		warn(NULL);
 		return 1;
 	}

Index: src/usr.bin/mail/cmd3.c
diff -u src/usr.bin/mail/cmd3.c:1.43 src/usr.bin/mail/cmd3.c:1.44
--- src/usr.bin/mail/cmd3.c:1.43	Tue Dec 16 14:30:24 2014
+++ src/usr.bin/mail/cmd3.c	Thu Nov  9 15:27:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cmd3.c,v 1.43 2014/12/16 19:30:24 christos Exp $	*/
+/*	$NetBSD: cmd3.c,v 1.44 2017/11/09 20:27:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)cmd3.c	8.2 (Berkeley) 4/20/95";
 #else
-__RCSID("$NetBSD: cmd3.c,v 1.43 2014/12/16 19:30:24 christos Exp $");
+__RCSID("$NetBSD: cmd3.c,v 1.44 2017/11/09 20:27:50 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -501,7 +501,7 @@ bounce_one(int msgno, const char **smarg
 	(void)snprintf(mailtempname, sizeof(mailtempname),
 	    "%s/mail.RsXXXXXXXXXX", tmpdir);
 	if ((fd = mkstemp(mailtempname)) == -1 ||
-	    (obuf = Fdopen(fd, "we+")) == NULL) {
+	    (obuf = Fdopen(fd, "wef+")) == NULL) {
 		if (fd != -1)
 			(void)close(fd);
 		warn("%s", mailtempname);
Index: src/usr.bin/mail/lex.c
diff -u src/usr.bin/mail/lex.c:1.43 src/usr.bin/mail/lex.c:1.44
--- src/usr.bin/mail/lex.c:1.43	Wed Feb 20 09:38:13 2013
+++ src/usr.bin/mail/lex.c	Thu Nov  9 15:27:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lex.c,v 1.43 2013/02/20 14:38:13 christos Exp $	*/
+/*	$NetBSD: lex.c,v 1.44 2017/11/09 20:27:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)lex.c	8.2 (Berkeley) 4/20/95";
 #else
-__RCSID("$NetBSD: lex.c,v 1.43 2013/02/20 14:38:13 christos Exp $");
+__RCSID("$NetBSD: lex.c,v 1.44 2017/11/09 20:27:50 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -214,7 +214,7 @@ setfile(const char *name)
 	if ((name = expand(name)) == NULL)
 		return -1;
 
-	if ((ibuf = Fopen(name, "re")) == NULL) {
+	if ((ibuf = Fopen(name, "ref")) == NULL) {
 		if (!isedit && errno == ENOENT)
 			goto nomail;
 		warn("Can't open `%s'", name);
@@ -278,9 +278,9 @@ setfile(const char *name)
 	(void)snprintf(tempname, sizeof(tempname),
 	    "%s/mail.RxXXXXXXXXXX", tmpdir);
 	if ((fd = mkstemp(tempname)) == -1 ||
-	    (otf = fdopen(fd, "we")) == NULL)
+	    (otf = fdopen(fd, "wef")) == NULL)
 		err(EXIT_FAILURE, "Can't create tmp file `%s'", tempname);
-	if ((itf = fopen(tempname, "re")) == NULL)
+	if ((itf = fopen(tempname, "ref")) == NULL)
 		err(EXIT_FAILURE, "Can't create tmp file `%s'", tempname);
 	(void)rm(tempname);
 	setptr(ibuf, (off_t)0);
@@ -317,7 +317,7 @@ incfile(void)
 
 	omsgCount = get_abs_msgCount();
 
-	ibuf = Fopen(mailname, "re");
+	ibuf = Fopen(mailname, "ref");
 	if (ibuf == NULL)
 		return -1;
 	sig_check();
@@ -1121,7 +1121,7 @@ load(const char *name)
 {
 	FILE *in, *oldin;
 
-	if ((in = Fopen(name, "re")) == NULL)
+	if ((in = Fopen(name, "ref")) == NULL)
 		return;
 	oldin = input;
 	input = in;

Index: src/usr.bin/mail/collect.c
diff -u src/usr.bin/mail/collect.c:1.48 src/usr.bin/mail/collect.c:1.49
--- src/usr.bin/mail/collect.c:1.48	Mon May  1 23:29:14 2017
+++ src/usr.bin/mail/collect.c	Thu Nov  9 15:27:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: collect.c,v 1.48 2017/05/02 03:29:14 christos Exp $	*/
+/*	$NetBSD: collect.c,v 1.49 2017/11/09 20:27:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)collect.c	8.2 (Berkeley) 4/19/94";
 #else
-__RCSID("$NetBSD: collect.c,v 1.48 2017/05/02 03:29:14 christos Exp $");
+__RCSID("$NetBSD: collect.c,v 1.49 2017/11/09 20:27:50 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -165,7 +165,7 @@ mespipe(FILE *fp, char cmd[])
 	(void)snprintf(tempname, sizeof(tempname),
 	    "%s/mail.ReXXXXXXXXXX", tmpdir);
 	if ((fd = mkstemp(tempname)) == -1 ||
-	    (nf = Fdopen(fd, "we+")) == NULL) {
+	    (nf = Fdopen(fd, "wef+")) == NULL) {
 		if (fd != -1)
 			(void)close(fd);
 		warn("%s", tempname);
@@ -403,7 +403,7 @@ collect(struct header *hp, int printhead
 	(void)snprintf(mailtempname, sizeof(mailtempname),
 	    "%s/mail.RsXXXXXXXXXX", tmpdir);
 	if ((fd = mkstemp(mailtempname)) == -1 ||
-	    (collf = Fdopen(fd, "we+")) == NULL) {
+	    (collf = Fdopen(fd, "wef+")) == NULL) {
 		if (fd != -1)
 			(void)close(fd);
 		warn("%s", mailtempname);
@@ -634,7 +634,7 @@ collect(struct header *hp, int printhead
 				(void)snprintf(tempname, sizeof(tempname),
 				    "%s/mail.ReXXXXXXXXXX", tmpdir);
 				if ((fd = mkstemp(tempname)) == -1 ||
-				    (fbuf = Fdopen(fd, "we+")) == NULL) {
+				    (fbuf = Fdopen(fd, "wef+")) == NULL) {
 					if (fd != -1)
 						(void)close(fd);
 					warn("%s", tempname);

Index: src/usr.bin/mail/edit.c
diff -u src/usr.bin/mail/edit.c:1.28 src/usr.bin/mail/edit.c:1.29
--- src/usr.bin/mail/edit.c:1.28	Wed Feb  3 00:18:58 2016
+++ src/usr.bin/mail/edit.c	Thu Nov  9 15:27:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: edit.c,v 1.28 2016/02/03 05:18:58 christos Exp $	*/
+/*	$NetBSD: edit.c,v 1.29 2017/11/09 20:27:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)edit.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: edit.c,v 1.28 2016/02/03 05:18:58 christos Exp $");
+__RCSID("$NetBSD: edit.c,v 1.29 2017/11/09 20:27:50 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -77,7 +77,7 @@ run_editor(FILE *fp, off_t size, int edi
 		(void)unlink(tempname);
 		goto out;
 	}
-	if ((nf = Fdopen(t, "we")) == NULL) {
+	if ((nf = Fdopen(t, "wef")) == NULL) {
 		(void)close(t);
 		warn("%s", tempname);
 		(void)unlink(tempname);
@@ -134,7 +134,7 @@ run_editor(FILE *fp, off_t size, int edi
 	/*
 	 * Now switch to new file.
 	 */
-	if ((nf = Fopen(tempname, "ae+")) == NULL) {
+	if ((nf = Fopen(tempname, "aef+")) == NULL) {
 		warn("%s", tempname);
 		(void)unlink(tempname);
 		goto out;
Index: src/usr.bin/mail/quit.c
diff -u src/usr.bin/mail/quit.c:1.28 src/usr.bin/mail/quit.c:1.29
--- src/usr.bin/mail/quit.c:1.28	Sun Apr 29 19:50:22 2012
+++ src/usr.bin/mail/quit.c	Thu Nov  9 15:27:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: quit.c,v 1.28 2012/04/29 23:50:22 christos Exp $	*/
+/*	$NetBSD: quit.c,v 1.29 2017/11/09 20:27:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)quit.c	8.2 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: quit.c,v 1.28 2012/04/29 23:50:22 christos Exp $");
+__RCSID("$NetBSD: quit.c,v 1.29 2017/11/09 20:27:50 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -79,7 +79,7 @@ writeback(FILE *res)
 	FILE *obuf;
 
 	p = 0;
-	if ((obuf = Fopen(mailname, "re+")) == NULL) {
+	if ((obuf = Fopen(mailname, "ref+")) == NULL) {
 		warn("%s", mailname);
 		return -1;
 	}
@@ -150,7 +150,7 @@ edstop(jmp_buf jmpbuf)
 
 	readstat = NULL;
 	if (Tflag != NULL) {
-		if ((readstat = Fopen(Tflag, "we")) == NULL)
+		if ((readstat = Fopen(Tflag, "wef")) == NULL)
 			Tflag = NULL;
 	}
 	for (mp = get_message(1), gotcha = 0; mp; mp = next_message(mp)) {
@@ -176,14 +176,14 @@ edstop(jmp_buf jmpbuf)
 		(void)snprintf(tempname, sizeof(tempname),
 		    "%s/mbox.XXXXXXXXXX", tmpdir);
 		if ((fd = mkstemp(tempname)) == -1 ||
-		    (obuf = Fdopen(fd, "we")) == NULL) {
+		    (obuf = Fdopen(fd, "wef")) == NULL) {
 			warn("%s", tempname);
 			if (fd != -1)
 				(void)close(fd);
 			sig_release();
 			longjmp(jmpbuf, -11);
 		}
-		if ((ibuf = Fopen(mailname, "re")) == NULL) {
+		if ((ibuf = Fopen(mailname, "ref")) == NULL) {
 			warn("%s", mailname);
 			(void)Fclose(obuf);
 			(void)rm(tempname);
@@ -204,7 +204,7 @@ edstop(jmp_buf jmpbuf)
 		}
 		(void)Fclose(ibuf);
 		(void)Fclose(obuf);
-		if ((ibuf = Fopen(tempname, "re")) == NULL) {
+		if ((ibuf = Fopen(tempname, "ref")) == NULL) {
 			warn("%s", tempname);
 			(void)rm(tempname);
 			sig_release();
@@ -214,7 +214,7 @@ edstop(jmp_buf jmpbuf)
 	}
 	(void)printf("\"%s\" ", mailname);
 	(void)fflush(stdout);
-	if ((obuf = Fopen(mailname, "re+")) == NULL) {
+	if ((obuf = Fopen(mailname, "ref+")) == NULL) {
 		warn("%s", mailname);
 		sig_release();
 		longjmp(jmpbuf, -1);
@@ -307,7 +307,7 @@ quit(jmp_buf jmpbuf)
 	 * a message.
 	 */
 
-	fbuf = Fopen(mailname, "re");
+	fbuf = Fopen(mailname, "ref");
 	if (fbuf == NULL)
 		goto newmail;
 	if (flock(fileno(fbuf), LOCK_EX) == -1) {
@@ -324,7 +324,7 @@ nolock:
 		(void)snprintf(tempname, sizeof(tempname),
 		    "%s/mail.RqXXXXXXXXXX", tmpdir);
 		if ((fd = mkstemp(tempname)) == -1 ||
-		    (rbuf = Fdopen(fd, "we")) == NULL) {
+		    (rbuf = Fdopen(fd, "wef")) == NULL) {
 		    	if (fd != -1)
 				(void)close(fd);
 			goto newmail;
@@ -351,7 +351,7 @@ nolock:
 			return;
 		}
 		(void)Fclose(rbuf);
-		if ((rbuf = Fopen(tempname, "re")) == NULL)
+		if ((rbuf = Fopen(tempname, "ref")) == NULL)
 			goto newmail;
 		(void)rm(tempname);
 	}
@@ -380,7 +380,7 @@ nolock:
 	}
 	modify = 0;
 	if (Tflag != NULL) {
-		if ((readstat = Fopen(Tflag, "we")) == NULL)
+		if ((readstat = Fopen(Tflag, "wef")) == NULL)
 			Tflag = NULL;
 	}
 	for (c = 0, p = 0, mp = get_message(1); mp; mp = next_message(mp)) {
@@ -430,7 +430,7 @@ nolock:
 		(void)snprintf(tempname, sizeof(tempname),
 		    "%s/mail.RmXXXXXXXXXX", tmpdir);
 		if ((fd = mkstemp(tempname)) == -1 ||
-		    (obuf = Fdopen(fd, "we")) == NULL) {
+		    (obuf = Fdopen(fd, "wef")) == NULL) {
 			warn("%s", tempname);
 			if (fd != -1)
 				(void)close(fd);
@@ -438,7 +438,7 @@ nolock:
 			dot_unlock(mailname);
 			return;
 		}
-		if ((ibuf = Fopen(tempname, "re")) == NULL) {
+		if ((ibuf = Fopen(tempname, "ref")) == NULL) {
 			warn("%s", tempname);
 			(void)rm(tempname);
 			(void)Fclose(obuf);
@@ -447,7 +447,7 @@ nolock:
 			return;
 		}
 		(void)rm(tempname);
-		if ((abuf = Fopen(mbox, "re")) != NULL) {
+		if ((abuf = Fopen(mbox, "ref")) != NULL) {
 			while ((c = getc(abuf)) != EOF)
 				(void)putc(c, obuf);
 			(void)Fclose(abuf);
@@ -463,7 +463,7 @@ nolock:
 		(void)Fclose(obuf);
 		if ((fd = creat(mbox, 0600)) != -1)
 			(void)close(fd);
-		if ((obuf = Fopen(mbox, "re+")) == NULL) {
+		if ((obuf = Fopen(mbox, "ref+")) == NULL) {
 			warn("%s", mbox);
 			(void)Fclose(ibuf);
 			(void)Fclose(fbuf);
@@ -472,7 +472,7 @@ nolock:
 		}
 	}
 	else {
-		if ((obuf = Fopen(mbox, "ae")) == NULL) {
+		if ((obuf = Fopen(mbox, "aef")) == NULL) {
 			warn("%s", mbox);
 			(void)Fclose(fbuf);
 			dot_unlock(mailname);
@@ -544,7 +544,7 @@ nolock:
 
 cream:
 	if (rbuf != NULL) {
-		abuf = Fopen(mailname, "re+");
+		abuf = Fopen(mailname, "ref+");
 		if (abuf == NULL)
 			goto newmail;
 		while ((c = getc(rbuf)) != EOF)

Index: src/usr.bin/mail/fio.c
diff -u src/usr.bin/mail/fio.c:1.42 src/usr.bin/mail/fio.c:1.43
--- src/usr.bin/mail/fio.c:1.42	Sat Jan 10 12:16:01 2015
+++ src/usr.bin/mail/fio.c	Thu Nov  9 15:27:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: fio.c,v 1.42 2015/01/10 17:16:01 christos Exp $	*/
+/*	$NetBSD: fio.c,v 1.43 2017/11/09 20:27:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)fio.c	8.2 (Berkeley) 4/20/95";
 #else
-__RCSID("$NetBSD: fio.c,v 1.42 2015/01/10 17:16:01 christos Exp $");
+__RCSID("$NetBSD: fio.c,v 1.43 2017/11/09 20:27:50 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -190,7 +190,7 @@ setptr(FILE *ibuf, off_t offset)
 	/* Get temporary file. */
 	(void)snprintf(linebuf, LINESIZE, "%s/mail.XXXXXX", tmpdir);
 	if ((c = mkstemp(linebuf)) == -1 ||
-	    (mestmp = Fdopen(c, "re+")) == NULL) {
+	    (mestmp = Fdopen(c, "ref+")) == NULL) {
 		(void)fprintf(stderr, "mail: can't open %s\n", linebuf);
 		exit(1);
 	}

Index: src/usr.bin/mail/list.c
diff -u src/usr.bin/mail/list.c:1.27 src/usr.bin/mail/list.c:1.28
--- src/usr.bin/mail/list.c:1.27	Sun Apr 29 19:50:22 2012
+++ src/usr.bin/mail/list.c	Thu Nov  9 15:27:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: list.c,v 1.27 2012/04/29 23:50:22 christos Exp $	*/
+/*	$NetBSD: list.c,v 1.28 2017/11/09 20:27:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)list.c	8.4 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: list.c,v 1.27 2012/04/29 23:50:22 christos Exp $");
+__RCSID("$NetBSD: list.c,v 1.28 2017/11/09 20:27:50 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -626,7 +626,7 @@ matchbody(int (*cmpfn)(void *, char *, s
 		fp = NULL;
 		if ((fd = mkstemp(tempname)) != -1) {
 			(void)unlink(tempname);
-			if ((fp = Fdopen(fd, "we+")) == NULL)
+			if ((fp = Fdopen(fd, "wef+")) == NULL)
 				(void)close(fd);
 		}
 		if (fp == NULL) {

Index: src/usr.bin/mail/mime_attach.c
diff -u src/usr.bin/mail/mime_attach.c:1.18 src/usr.bin/mail/mime_attach.c:1.19
--- src/usr.bin/mail/mime_attach.c:1.18	Tue Jun 16 20:03:42 2015
+++ src/usr.bin/mail/mime_attach.c	Thu Nov  9 15:27:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mime_attach.c,v 1.18 2015/06/17 00:03:42 christos Exp $	*/
+/*	$NetBSD: mime_attach.c,v 1.19 2017/11/09 20:27:50 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 #ifndef __lint__
-__RCSID("$NetBSD: mime_attach.c,v 1.18 2015/06/17 00:03:42 christos Exp $");
+__RCSID("$NetBSD: mime_attach.c,v 1.19 2017/11/09 20:27:50 christos Exp $");
 #endif /* not __lint__ */
 
 #include <assert.h>
@@ -273,7 +273,7 @@ content_encoding_by_name(const char *fil
 {
 	FILE *fp;
 	const char *enc;
-	fp = Fopen(filename, "re");
+	fp = Fopen(filename, "ref");
 	if (fp == NULL) {
 		warn("content_encoding_by_name: %s", filename);
 		return MIME_TRANSFER_BASE64;	/* safe */
@@ -293,7 +293,7 @@ content_encoding_by_fileno(int fd, const
 
 	cur_pos = lseek(fd, (off_t)0, SEEK_CUR);
 	if ((fd2 = dup(fd)) == -1 ||
-	    (fp = Fdopen(fd2, "re")) == NULL) {
+	    (fp = Fdopen(fd2, "ref")) == NULL) {
 		warn("content_encoding_by_fileno");
 		if (fd2 != -1)
 			(void)close(fd2);
@@ -356,7 +356,7 @@ content_type_by_name(char *filename)
 			int ch;
 
 			if (sb.st_size == 0 || filename == NULL ||
-			    (fp = Fopen(filename, "re")) == NULL)
+			    (fp = Fopen(filename, "ref")) == NULL)
 				return "text/plain";
 
 			ch = fgetc(fp);
@@ -545,7 +545,7 @@ fput_attachment(FILE *fo, struct attachm
 
 	switch (ap->a_type) {
 	case ATTACH_FNAME:
-		fi = Fopen(ap->a_name, "re");
+		fi = Fopen(ap->a_name, "ref");
 		if (fi == NULL)
 			err(EXIT_FAILURE, "Fopen: %s", ap->a_name);
 		break;
@@ -556,7 +556,7 @@ fput_attachment(FILE *fo, struct attachm
 		 * finished with the attachment, so the Fclose() below
 		 * is OK for now.  This will be changed in the future.
 		 */
-		fi = Fdopen(ap->a_fileno, "re");
+		fi = Fdopen(ap->a_fileno, "ref");
 		if (fi == NULL)
 			err(EXIT_FAILURE, "Fdopen: %d", ap->a_fileno);
 		break;
@@ -569,7 +569,7 @@ fput_attachment(FILE *fo, struct attachm
 		(void)snprintf(mailtempname, sizeof(mailtempname),
 		    "%s/mail.RsXXXXXXXXXX", tmpdir);
 		if ((fd = mkstemp(mailtempname)) == -1 ||
-		    (fi = Fdopen(fd, "we+")) == NULL) {
+		    (fi = Fdopen(fd, "wef+")) == NULL) {
 			if (fd != -1)
 				(void)close(fd);
 			err(EXIT_FAILURE, "%s", mailtempname);
@@ -614,7 +614,7 @@ mktemp_file(FILE **nfo, FILE **nfi, cons
 	(void)snprintf(tempname, sizeof(tempname), "%s/%sXXXXXXXXXX",
 	    tmpdir, hint);
 	if ((fd = mkstemp(tempname)) == -1 ||
-	    (*nfo = Fdopen(fd, "we")) == NULL) {
+	    (*nfo = Fdopen(fd, "wef")) == NULL) {
 		if (fd != -1)
 			(void)close(fd);
 		warn("%s", tempname);
@@ -622,7 +622,7 @@ mktemp_file(FILE **nfo, FILE **nfi, cons
 	}
 	(void)rm(tempname);
 	if ((fd2 = dup(fd)) == -1 ||
-	    (*nfi = Fdopen(fd2, "re")) == NULL) {
+	    (*nfi = Fdopen(fd2, "ref")) == NULL) {
 		warn("%s", tempname);
 		(void)Fclose(*nfo);
 		return -1;

Index: src/usr.bin/mail/mime_child.c
diff -u src/usr.bin/mail/mime_child.c:1.8 src/usr.bin/mail/mime_child.c:1.9
--- src/usr.bin/mail/mime_child.c:1.8	Sun Apr 29 19:50:22 2012
+++ src/usr.bin/mail/mime_child.c	Thu Nov  9 15:27:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mime_child.c,v 1.8 2012/04/29 23:50:22 christos Exp $	*/
+/*	$NetBSD: mime_child.c,v 1.9 2017/11/09 20:27:50 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>
 #ifndef __lint__
-__RCSID("$NetBSD: mime_child.c,v 1.8 2012/04/29 23:50:22 christos Exp $");
+__RCSID("$NetBSD: mime_child.c,v 1.9 2017/11/09 20:27:50 christos Exp $");
 #endif /* not __lint__ */
 
 #include <assert.h>
@@ -159,7 +159,7 @@ mime_run_command(const char *cmd, FILE *
 	default:	/* parent */
 		(void)close(p[READ]);
 
-		nfo = fdopen(p[WRITE], "w");
+		nfo = fdopen(p[WRITE], "wef");
 		if (nfo == NULL) {
 			warn("mime_run_command: fdopen");
 			(void)close(p[WRITE]);
@@ -203,7 +203,7 @@ mime_run_function(void (*fn)(FILE *, FIL
 
 	default:	/* parent */
 		(void)close(p[READ]);
-		nfo = fdopen(p[WRITE], "w");
+		nfo = fdopen(p[WRITE], "wef");
 		if (nfo == NULL) {
 			warn("run_function: fdopen");
 			(void)close(p[WRITE]);
Index: src/usr.bin/mail/mime_detach.c
diff -u src/usr.bin/mail/mime_detach.c:1.8 src/usr.bin/mail/mime_detach.c:1.9
--- src/usr.bin/mail/mime_detach.c:1.8	Sun Apr 29 19:50:22 2012
+++ src/usr.bin/mail/mime_detach.c	Thu Nov  9 15:27:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mime_detach.c,v 1.8 2012/04/29 23:50:22 christos Exp $	*/
+/*	$NetBSD: mime_detach.c,v 1.9 2017/11/09 20:27:50 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>
 #ifndef __lint__
-__RCSID("$NetBSD: mime_detach.c,v 1.8 2012/04/29 23:50:22 christos Exp $");
+__RCSID("$NetBSD: mime_detach.c,v 1.9 2017/11/09 20:27:50 christos Exp $");
 #endif /* not __lint__ */
 
 #include <assert.h>
@@ -126,7 +126,7 @@ detach_open_core(char *fname, const char
 	flags = (detach_ctl.overwrite ? 0 : O_EXCL) | O_CREAT | O_TRUNC | O_WRONLY;
 
 	if ((fd = open(fname, flags | O_CLOEXEC, 0600)) != -1 &&
-	    Fdopen(fd, "we") != NULL)
+	    Fdopen(fd, "wef") != NULL)
 		return DETACH_OPEN_OK;
 
 	if (detach_ctl.ask && fd == -1 && errno == EEXIST) {
@@ -147,7 +147,7 @@ detach_open_core(char *fname, const char
 				detach_ctl.ask = 0;
 				/* FALLTHROUGH */
 		case 'o':
-			if (Fopen(fname, "we") != NULL)
+			if (Fopen(fname, "wef") != NULL)
 				return DETACH_OPEN_OK;
 			break;
 

Index: src/usr.bin/mail/names.c
diff -u src/usr.bin/mail/names.c:1.32 src/usr.bin/mail/names.c:1.33
--- src/usr.bin/mail/names.c:1.32	Sat Jan 10 12:16:01 2015
+++ src/usr.bin/mail/names.c	Thu Nov  9 15:27:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: names.c,v 1.32 2015/01/10 17:16:01 christos Exp $	*/
+/*	$NetBSD: names.c,v 1.33 2017/11/09 20:27:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)names.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: names.c,v 1.32 2015/01/10 17:16:01 christos Exp $");
+__RCSID("$NetBSD: names.c,v 1.33 2017/11/09 20:27:50 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -289,7 +289,7 @@ outof(struct name *names, FILE *fo, stru
 			(void)snprintf(tempname, sizeof(tempname),
 			    "%s/mail.ReXXXXXXXXXXXX", tmpdir);
 			if ((fd = mkstemp(tempname)) == -1 ||
-			    (fout = Fdopen(fd, "ae")) == NULL) {
+			    (fout = Fdopen(fd, "aef")) == NULL) {
 				if (fd != -1)
 					(void)close(fd);
 				warn("%s", tempname);
@@ -357,7 +357,7 @@ outof(struct name *names, FILE *fo, stru
 			free_child(pid);
 		} else {
 			int f;
-			if ((fout = Fopen(fname, "ae")) == NULL) {
+			if ((fout = Fopen(fname, "aef")) == NULL) {
 				warn("%s", fname);
 				senderr++;
 				goto cant;
@@ -366,7 +366,7 @@ outof(struct name *names, FILE *fo, stru
 				warn("dup");
 				fin = NULL;
 			} else
-				fin = Fdopen(f, "re");
+				fin = Fdopen(f, "ref");
 			if (fin == NULL) {
 				(void)fprintf(stderr, "Can't reopen image\n");
 				(void)Fclose(fout);

Index: src/usr.bin/mail/send.c
diff -u src/usr.bin/mail/send.c:1.38 src/usr.bin/mail/send.c:1.39
--- src/usr.bin/mail/send.c:1.38	Tue Dec 16 14:30:24 2014
+++ src/usr.bin/mail/send.c	Thu Nov  9 15:27:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: send.c,v 1.38 2014/12/16 19:30:24 christos Exp $	*/
+/*	$NetBSD: send.c,v 1.39 2017/11/09 20:27:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)send.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: send.c,v 1.38 2014/12/16 19:30:24 christos Exp $");
+__RCSID("$NetBSD: send.c,v 1.39 2017/11/09 20:27:50 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -487,13 +487,13 @@ infix(struct header *hp, FILE *fi)
 	(void)snprintf(tempname, sizeof(tempname),
 	    "%s/mail.RsXXXXXXXXXX", tmpdir);
 	if ((fd = mkstemp(tempname)) == -1 ||
-	    (nfo = Fdopen(fd, "we")) == NULL) {
+	    (nfo = Fdopen(fd, "wef")) == NULL) {
 		if (fd != -1)
 			(void)close(fd);
 		warn("%s", tempname);
 		return fi;
 	}
-	if ((nfi = Fopen(tempname, "re")) == NULL) {
+	if ((nfi = Fopen(tempname, "ref")) == NULL) {
 		warn("%s", tempname);
 		(void)Fclose(nfo);
 		(void)rm(tempname);
@@ -553,7 +553,7 @@ savemail(const char name[], FILE *fi)
 	int afterblank;
 
 	m = umask(077);
-	fo = Fopen(name, "ae");
+	fo = Fopen(name, "aef");
 	(void)umask(m);
 	if (fo == NULL) {
 		warn("%s", name);

Index: src/usr.bin/mail/support.c
diff -u src/usr.bin/mail/support.c:1.24 src/usr.bin/mail/support.c:1.25
--- src/usr.bin/mail/support.c:1.24	Sun Apr 29 19:50:22 2012
+++ src/usr.bin/mail/support.c	Thu Nov  9 15:27:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: support.c,v 1.24 2012/04/29 23:50:22 christos Exp $	*/
+/*	$NetBSD: support.c,v 1.25 2017/11/09 20:27:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)aux.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: support.c,v 1.24 2012/04/29 23:50:22 christos Exp $");
+__RCSID("$NetBSD: support.c,v 1.25 2017/11/09 20:27:50 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -336,7 +336,7 @@ source(void *v)
 
 	if ((cp = expand(*arglist)) == NULL)
 		return 1;
-	if ((fi = Fopen(cp, "re")) == NULL) {
+	if ((fi = Fopen(cp, "ref")) == NULL) {
 		warn("%s", cp);
 		return 1;
 	}
@@ -732,7 +732,7 @@ cathelp(const char *fname)
 	FILE *f;
 	size_t len;
 
-	if ((f = Fopen(fname, "re")) == NULL) {
+	if ((f = Fopen(fname, "ref")) == NULL) {
 		warn("%s", fname);
 		return;
 	}

Reply via email to