summaryrefslogtreecommitdiff
path: root/usr.bin/m4
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1996-09-15 19:05:10 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1996-09-15 19:05:10 +0000
commit5f33e4ba21382f50bdc7a980885aac76fac8c71b (patch)
tree07282d3cb142a1d3b2e286be09b82b47ca84b125 /usr.bin/m4
parent9c7c873d1a4767b9c5c15c1747a0ad5919b7eb38 (diff)
Slightly safer temp file open.
Diffstat (limited to 'usr.bin/m4')
-rw-r--r--usr.bin/m4/serv.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/m4/serv.c b/usr.bin/m4/serv.c
index e423c5987d2..6658e6fda79 100644
--- a/usr.bin/m4/serv.c
+++ b/usr.bin/m4/serv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: serv.c,v 1.4 1996/07/01 20:40:29 deraadt Exp $ */
+/* $OpenBSD: serv.c,v 1.5 1996/09/15 19:05:09 millert Exp $ */
/* $NetBSD: serv.c,v 1.7 1995/09/28 05:37:47 tls Exp $ */
/*
@@ -46,7 +46,7 @@
#if 0
static char sccsid[] = "@(#)serv.c 5.4 (Berkeley) 1/21/94";
#else
-static char rcsid[] = "$OpenBSD: serv.c,v 1.4 1996/07/01 20:40:29 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: serv.c,v 1.5 1996/09/15 19:05:09 millert Exp $";
#endif
#endif /* not lint */
@@ -59,6 +59,7 @@ static char rcsid[] = "$OpenBSD: serv.c,v 1.4 1996/07/01 20:40:29 deraadt Exp $"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <fcntl.h>
#include "mdef.h"
#include "extr.h"
#include "pathnames.h"
@@ -337,11 +338,14 @@ register int argc;
dodiv(n)
register int n;
{
+ int fd;
+
if (n < 0 || n >= MAXOUT)
n = 0; /* bitbucket */
if (outfile[n] == NULL) {
m4temp[UNIQUE] = n + '0';
- if ((outfile[n] = fopen(m4temp, "w")) == NULL)
+ if ((fd = open(m4temp, O_CREAT|O_EXCL|O_WRONLY, 0600)) < 0 ||
+ (outfile[n] = fdopen(fd, "w")) == NULL)
error("m4: cannot divert.");
}
oindex = n;