Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bounties #608

Merged
merged 3 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tar/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ tree_next(struct tree *t)
if (de == NULL) {
if (errno) {
/* If readdir fails, we're screwed. */
t->tree_errno = errno;
closedir(t->d);
t->d = NULL;
t->visit_type = TREE_ERROR_FATAL;
Expand Down Expand Up @@ -438,16 +439,16 @@ tree_next(struct tree *t)
t->dirname_length = t->path_length;
if (chdir(t->stack->name) != 0) {
/* chdir() failed; return error */
tree_pop(t);
t->tree_errno = errno;
tree_pop(t);
return (t->visit_type = TREE_ERROR_DIR);
}
t->depth++;
t->d = opendir(".");
if (t->d == NULL) {
t->tree_errno = errno;
r = tree_ascend(t); /* Undo "chdir" */
tree_pop(t);
t->tree_errno = errno;
t->visit_type = r != 0 ? r : TREE_ERROR_DIR;
return (t->visit_type);
}
Expand Down
3 changes: 2 additions & 1 deletion tar/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ int tree_close(struct tree *);
* fatal error, but it does imply that the relevant subtree won't be
* visited. TREE_ERROR_FATAL is returned for an error that left the
* traversal completely hosed. Right now, this is only returned for
* chdir() failures during ascent.
* chdir() failures during ascent, or readdir() failures when looking
* for the next entry.
*/
#define TREE_REGULAR 1
#define TREE_POSTDESCENT 2
Expand Down
2 changes: 1 addition & 1 deletion tar/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ write_hierarchy(struct bsdtar *bsdtar, struct archive *a, const char *path)
"%s: Unable to continue traversing directory tree",
name);
if (tree_ret == TREE_ERROR_DIR) {
bsdtar_warnc(bsdtar, errno,
bsdtar_warnc(bsdtar, tree_errno(tree),
"%s: Couldn't visit directory", name);
bsdtar->return_value = 1;
}
Expand Down