projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
check that chdir worked before trying to read directory (genji@topaz)
[unix-history]
/
usr
/
src
/
old
/
tar
/
tar.c
diff --git
a/usr/src/old/tar/tar.c
b/usr/src/old/tar/tar.c
index
5481408
..
afe096c
100644
(file)
--- a/
usr/src/old/tar/tar.c
+++ b/
usr/src/old/tar/tar.c
@@
-1,5
+1,5
@@
#ifndef lint
#ifndef lint
-static char *sccsid = "@(#)tar.c 4.1
8
(Berkeley) %G%";
+static char *sccsid = "@(#)tar.c 4.1
9
(Berkeley) %G%";
#endif
/*
#endif
/*
@@
-333,7
+333,10
@@
dorep(argv)
cp2++;
}
putfile(*argv++, cp2, parent);
cp2++;
}
putfile(*argv++, cp2, parent);
- chdir(wdir);
+ if (chdir(wdir) < 0) {
+ fprintf(stderr, "cannot change back?: ");
+ perror(wdir);
+ }
}
putempty();
putempty();
}
putempty();
putempty();
@@
-457,11
+460,17
@@
putfile(longname, shortname, parent)
writetape((char *)&dblock);
}
sprintf(newparent, "%s/%s", parent, shortname);
writetape((char *)&dblock);
}
sprintf(newparent, "%s/%s", parent, shortname);
- chdir(shortname);
+ if (chdir(shortname) < 0) {
+ perror(shortname);
+ return;
+ }
if ((dirp = opendir(".")) == NULL) {
fprintf(stderr, "tar: %s: directory read error\n",
longname);
if ((dirp = opendir(".")) == NULL) {
fprintf(stderr, "tar: %s: directory read error\n",
longname);
- chdir(parent);
+ if (chdir(parent) < 0) {
+ fprintf(stderr, "cannot change back?: ");
+ perror(parent);
+ }
return;
}
while ((dp = readdir(dirp)) != NULL && !term) {
return;
}
while ((dp = readdir(dirp)) != NULL && !term) {
@@
-478,7
+487,10
@@
putfile(longname, shortname, parent)
seekdir(dirp, i);
}
closedir(dirp);
seekdir(dirp, i);
}
closedir(dirp);
- chdir(parent);
+ if (chdir(parent) < 0) {
+ fprintf(stderr, "cannot change back?: ");
+ perror(parent);
+ }
break;
case S_IFLNK:
break;
case S_IFLNK: