diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-16 13:26:46 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-16 13:26:46 +0000 |
commit | f7f1f4bb7ce233e4d42df84e8bea4d7dfd840d23 (patch) | |
tree | fb9b29b043c6fdf0762fbd51a8805e7ff88dd6af | |
parent | b3ebfc3b59636444e318b1293aea1473b3aa2677 (diff) |
use unique temporary files; netbsd pr#2544; lukem@supp.cpr.itg.telecom.com.au
-rw-r--r-- | sbin/restore/dirs.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c index ddb70c4c208..377f1f983ca 100644 --- a/sbin/restore/dirs.c +++ b/sbin/restore/dirs.c @@ -111,9 +111,9 @@ struct rstdirdesc { static long seekpt; static FILE *df, *mf; static RST_DIR *dirp; -static char dirfile[32] = "#"; /* No file */ -static char modefile[32] = "#"; /* No file */ -static char dot[2] = "."; /* So it can be modified */ +static char dirfile[MAXPATHLEN] = "#"; /* No file */ +static char modefile[MAXPATHLEN] = "#"; /* No file */ +static char dot[2] = "."; /* So it can be modified */ /* * Format of old style directories. @@ -151,7 +151,13 @@ extractdirs(genmode) struct direct nulldir; vprintf(stdout, "Extract directories from tape\n"); - (void) sprintf(dirfile, "%s/rstdir%d", _PATH_TMP, dumpdate); + (void) sprintf(dirfile, "%s/rstdir%d-XXXXXX", _PATH_TMP, dumpdate); + if (mktemp(dirfile) == NULL) { + fprintf(stderr, + "restore: %s - cannot generate directory temporary\n", + dirfile); + exit(1); + } df = fopen(dirfile, "w"); if (df == NULL) { fprintf(stderr, @@ -161,7 +167,14 @@ extractdirs(genmode) exit(1); } if (genmode != 0) { - (void) sprintf(modefile, "%s/rstmode%d", _PATH_TMP, dumpdate); + (void) sprintf(modefile, "%s/rstmode%d-XXXXXX", _PATH_TMP, + dumpdate); + if (mktemp(modefile) == NULL) { + fprintf(stderr, + "restore: %s - cannot generate modefile\n", + modefile); + exit(1); + } mf = fopen(modefile, "w"); if (mf == NULL) { fprintf(stderr, |