diff options
author | peadar <peadar@FreeBSD.org> | 2006-02-22 11:13:07 +0000 |
---|---|---|
committer | peadar <peadar@FreeBSD.org> | 2006-02-22 11:13:07 +0000 |
commit | a1b7ff0a8318c4000ef725d92bc3f1ca8e1c74c8 (patch) | |
tree | 3f8a8c6ad8fcd353b6ca0cf0d84ffbec32c43189 /usr.bin/tar | |
parent | 33f484fce3e374fb5027c80d2008a6190d7b25c4 (diff) | |
download | FreeBSD-src-a1b7ff0a8318c4000ef725d92bc3f1ca8e1c74c8.zip FreeBSD-src-a1b7ff0a8318c4000ef725d92bc3f1ca8e1c74c8.tar.gz |
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@
Diffstat (limited to 'usr.bin/tar')
-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 4528eea..944a787 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 = "."; |