diff options
author | Peter Edwards <peadar@FreeBSD.org> | 2006-02-22 11:13:07 +0000 |
---|---|---|
committer | Peter Edwards <peadar@FreeBSD.org> | 2006-02-22 11:13:07 +0000 |
commit | d12dff713a2e35865857e8cd2c3dec71222ab3cc (patch) | |
tree | 3f8a8c6ad8fcd353b6ca0cf0d84ffbec32c43189 /usr.bin/tar/tree.c | |
parent | 91387563e27b056ed9b7de097693fa2469e5f79f (diff) | |
download | src-d12dff713a2e35865857e8cd2c3dec71222ab3cc.tar.gz src-d12dff713a2e35865857e8cd2c3dec71222ab3cc.zip |
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@
Notes
Notes:
svn path=/head/; revision=155908
Diffstat (limited to 'usr.bin/tar/tree.c')
-rw-r--r-- | usr.bin/tar/tree.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.bin/tar/tree.c b/usr.bin/tar/tree.c index 4528eea3c15b..944a787bcf47 100644 --- a/usr.bin/tar/tree.c +++ b/usr.bin/tar/tree.c @@ -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 = "."; |