Skip to content

Commit

Permalink
Merge pull request #608 from Tarsnap/bounties
Browse files Browse the repository at this point in the history
Bounties
  • Loading branch information
cperciva authored Feb 18, 2024
2 parents 783db72 + 6dd740e commit dc22f7f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
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

0 comments on commit dc22f7f

Please sign in to comment.