Deleted Added
full compact
107,109c107,109
< 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 */
144a145
> int fd;
147,149c148,156
< (void) sprintf(dirfile, "%s/rstdir%d", _PATH_TMP, dumpdate);
< df = fopen(dirfile, "w");
< if (df == NULL) {
---
> (void) sprintf(dirfile, "%srstdir%d", _PATH_TMP, dumpdate);
> if (command != 'r' && command != 'R') {
> (void *) strcat(dirfile, "-XXXXXX");
> fd = mkstemp(dirfile);
> } else
> fd = open(dirfile, O_RDWR|O_CREAT|O_EXCL, 0666);
> if (fd == -1 || (df = fdopen(fd, "w")) == NULL) {
> if (fd != -1)
> close(fd);
157,159c164,172
< (void) sprintf(modefile, "%s/rstmode%d", _PATH_TMP, dumpdate);
< mf = fopen(modefile, "w");
< if (mf == NULL) {
---
> (void) sprintf(modefile, "%srstmode%d", _PATH_TMP, dumpdate);
> if (command != 'r' && command != 'R') {
> (void *) strcat(modefile, "-XXXXXX");
> fd = mkstemp(modefile);
> } else
> fd = open(modefile, O_RDWR|O_CREAT|O_EXCL, 0666);
> if (fd == -1 || (mf = fdopen(fd, "w")) == NULL) {
> if (fd != -1)
> close(fd);
242,243c255,257
< (void) strncpy(locname, pname, MAXPATHLEN);
< (void) strncat(locname, "/", MAXPATHLEN);
---
> (void) strncpy(locname, pname, sizeof(locname) - 1);
> locname[sizeof(locname) - 1] = '\0';
> (void) strncat(locname, "/", sizeof(locname) - strlen(locname));
263c277
< if (namelen + dp->d_namlen >= MAXPATHLEN) {
---
> if (namelen + dp->d_namlen >= sizeof(locname)) {
265c279
< locname, dp->d_name, MAXPATHLEN);
---
> locname, dp->d_name, sizeof(locname) - 1);
588c602,608
< (void) sprintf(modefile, "%s/rstmode%d", _PATH_TMP, dumpdate);
---
> if (command == 'r' || command == 'R')
> (void) sprintf(modefile, "%srstmode%d", _PATH_TMP, dumpdate);
> if (modefile[0] == '#') {
> panic("modefile not defined\n");
> fprintf(stderr, "directory mode, owner, and times not set\n");
> return;
> }
643c663
< if ((ofile = creat(name, 0666)) < 0) {
---
> if ((ofile = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {