summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>1996-09-15 18:59:07 +0000
committermillert <millert@openbsd.org>1996-09-15 18:59:07 +0000
commit445b77f713f977acafe7fb9cc8b986a0c9677c1c (patch)
treeb67270b0475ccd8433c98b638798460a7e4b49c6 /usr.bin
parentBlind update of wosch@FreeBSD's code: (diff)
downloadwireguard-openbsd-445b77f713f977acafe7fb9cc8b986a0c9677c1c.tar.xz
wireguard-openbsd-445b77f713f977acafe7fb9cc8b986a0c9677c1c.zip
Slightly safer temp file open.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/m4/eval.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c
index ef14aa34604..636e113076c 100644
--- a/usr.bin/m4/eval.c
+++ b/usr.bin/m4/eval.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eval.c,v 1.5 1996/07/01 20:40:27 deraadt Exp $ */
+/* $OpenBSD: eval.c,v 1.6 1996/09/15 18:59:07 millert Exp $ */
/* $NetBSD: eval.c,v 1.5 1996/01/13 23:25:23 pk Exp $ */
/*
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)eval.c 8.2 (Berkeley) 4/27/95";
#else
-static char rcsid[] = "$OpenBSD: eval.c,v 1.5 1996/07/01 20:40:27 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: eval.c,v 1.6 1996/09/15 18:59:07 millert Exp $";
#endif
#endif /* not lint */
@@ -57,6 +57,7 @@ static char rcsid[] = "$OpenBSD: eval.c,v 1.5 1996/07/01 20:40:27 deraadt Exp $"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <fcntl.h>
#include "mdef.h"
#include "stdd.h"
#include "extern.h"
@@ -664,11 +665,14 @@ void
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)
oops("%s: cannot divert.", m4temp);
}
oindex = n;