Dont chdir untill after we open the archive
diff --git a/archival/tar.c b/archival/tar.c
index f9711f8..cadab32 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -710,10 +710,6 @@
tar_handle->filter = filter_accept_reject_list;
}
- if ((base_dir) && (chdir(base_dir))) {
- perror_msg_and_die("Couldnt chdir");
- }
-
#ifdef CONFIG_FEATURE_TAR_CREATE
/* create an archive */
if (tar_create == TRUE) {
@@ -740,6 +736,11 @@
} else {
tar_handle->src_fd = xopen(tar_filename, O_RDONLY);
}
+
+ if ((base_dir) && (chdir(base_dir))) {
+ perror_msg_and_die("Couldnt chdir");
+ }
+
while (get_header_ptr(tar_handle) == EXIT_SUCCESS);
/* Ckeck that every file that should have been extracted was */