summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-09-16 01:47:07 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-09-16 01:47:07 +0000
commit5f11a8a706c9ee1c6314da299062b2a27fe54467 (patch)
treed884f0b8f0828a86f487ef0600e3f8feb9296f31 /usr.bin
parent0952c6249d044131ba5b4d9094cb817bda824eaa (diff)
use mkstemp correctly
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/error/touch.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.bin/error/touch.c b/usr.bin/error/touch.c
index d64a2bff770..d51cf06d2c0 100644
--- a/usr.bin/error/touch.c
+++ b/usr.bin/error/touch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: touch.c,v 1.3 1996/06/26 05:32:46 deraadt Exp $ */
+/* $OpenBSD: touch.c,v 1.4 1996/09/16 01:47:06 deraadt Exp $ */
/* $NetBSD: touch.c,v 1.3 1995/09/02 06:15:54 jtc Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)touch.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: touch.c,v 1.3 1996/06/26 05:32:46 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: touch.c,v 1.4 1996/09/16 01:47:06 deraadt Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -521,7 +521,6 @@ FILE *o_touchedfile; /* the old file */
FILE *n_touchedfile; /* the new file */
char *o_name;
char n_name[64];
-char *canon_name = _PATH_TMP;
int o_lineno;
int n_lineno;
boolean tempfileopen = FALSE;
@@ -540,7 +539,7 @@ boolean edit(name)
processname, name);
return(TRUE);
}
- (void)strcpy(n_name, canon_name);
+ snprintf(n_name, sizeof n_name, "%s/error.XXXXXXXX", _PATH_TMP);
if ((fd = mkstemp(n_name)) == -1 ||
(n_touchedfile = fdopen(fd, "w")) == NULL) {
if (fd != -1)
@@ -639,8 +638,9 @@ writetouched(overwrite)
fclose(tmpfile);
}
if (oktorm == 0){
- fprintf(stderr, "%s: Catastrophe: A copy of \"%s\": was saved in \"%s\"\n",
- processname, o_name, n_name);
+ fprintf(stderr,
+ "%s: Catastrophe: A copy of \"%s\": was saved in \"%s\"\n",
+ processname, o_name, n_name);
exit(1);
}
/*