diff options
| author | Warner Losh <imp@FreeBSD.org> | 1997-03-24 05:50:27 +0000 |
|---|---|---|
| committer | Warner Losh <imp@FreeBSD.org> | 1997-03-24 05:50:27 +0000 |
| commit | 1e545639ed7342d62e74a5c79b3b4022e19a43ef (patch) | |
| tree | b98756719a369cc346e604bc4a1eb5072826bb52 /usr.bin/error | |
| parent | e38b50134c006372cae65ca54eff497ca37376cb (diff) | |
Notes
Diffstat (limited to 'usr.bin/error')
| -rw-r--r-- | usr.bin/error/touch.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.bin/error/touch.c b/usr.bin/error/touch.c index b4348a17b916..a21c72d9acb8 100644 --- a/usr.bin/error/touch.c +++ b/usr.bin/error/touch.c @@ -37,6 +37,7 @@ static char sccsid[] = "@(#)touch.c 8.1 (Berkeley) 6/6/93"; #include <sys/types.h> #include <sys/stat.h> +#include <sys/param.h> #include <signal.h> #include <unistd.h> #include <stdio.h> @@ -514,7 +515,7 @@ execvarg(n_pissed_on, r_argc, r_argv) FILE *o_touchedfile; /* the old file */ FILE *n_touchedfile; /* the new file */ char *o_name; -char n_name[64]; +char n_name[MAXPATHLEN]; char *canon_name = _PATH_TMP; int o_lineno; int n_lineno; @@ -526,6 +527,8 @@ boolean tempfileopen = FALSE; boolean edit(name) char *name; { + int fd; + o_name = name; if ( (o_touchedfile = fopen(name, "r")) == NULL){ fprintf(stderr, "%s: Can't open file \"%s\" to touch (read).\n", @@ -533,8 +536,11 @@ boolean edit(name) return(TRUE); } (void)strcpy(n_name, canon_name); - (void)mktemp(n_name); - if ( (n_touchedfile = fopen(n_name, "w")) == NULL){ + (void)strcat(n_name,"error.XXXXXX"); + fd = mkstemp(n_name); + if ( fd < 0 || (n_touchedfile = fdopen(fd, "w")) == NULL) { + if (fd >= 0) + close(fd); fprintf(stderr,"%s: Can't open file \"%s\" to touch (write).\n", processname, name); return(TRUE); |
