If opendir(".") fails after descending into a subdirectory via

chdir(), be sure to undo the effects of the chdir before continuing.

Without this, after hitting a directory with mode 0111 (for example),
tar will get lost, and won't add any yet unvisted files to your
archive.  (Or possibly add the wrong files, I suppose...)

Reviewed By: kientzle@
This commit is contained in:
Peter Edwards 2006-02-22 11:13:07 +00:00
parent 91387563e2
commit d12dff713a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=155908

View file

@ -311,13 +311,14 @@ tree_next(struct tree *t)
t->tree_errno = errno;
return (t->visit_type = TREE_ERROR_DIR);
}
t->depth++;
t->d = opendir(".");
if (t->d == NULL) {
tree_ascend(t); /* Undo "chdir" */
tree_pop(t);
t->tree_errno = errno;
return (t->visit_type = TREE_ERROR_DIR);
}
t->depth++;
t->flags &= ~hasLstat;
t->flags &= ~hasStat;
t->basename = ".";