aboutsummaryrefslogtreecommitdiff
path: root/archival/unzip.c
diff options
context:
space:
mode:
Diffstat (limited to 'archival/unzip.c')
-rw-r--r--archival/unzip.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/archival/unzip.c b/archival/unzip.c
index 653fdd10f..0a27e5e18 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -343,7 +343,9 @@ static void unzip_create_leading_dirs(const char *fn)
}
#if ENABLE_FEATURE_UNZIP_CDF
-static void unzip_extract_symlink(zip_header_t *zip, const char *dst_fn)
+static void unzip_extract_symlink(llist_t **symlink_placeholders,
+ zip_header_t *zip,
+ const char *dst_fn)
{
char *target;
@@ -368,15 +370,9 @@ static void unzip_extract_symlink(zip_header_t *zip, const char *dst_fn)
target[xstate.mem_output_size] = '\0';
#endif
}
- if (!unsafe_symlink_target(target)) {
-//TODO: libbb candidate
- if (symlink(target, dst_fn)) {
- /* shared message */
- bb_perror_msg_and_die("can't create %slink '%s' to '%s'",
- "sym", dst_fn, target
- );
- }
- }
+ create_or_remember_symlink(symlink_placeholders,
+ target,
+ dst_fn);
free(target);
}
#endif
@@ -488,6 +484,9 @@ int unzip_main(int argc, char **argv)
llist_t *zaccept = NULL;
llist_t *zreject = NULL;
char *base_dir = NULL;
+#if ENABLE_FEATURE_UNZIP_CDF
+ llist_t *symlink_placeholders = NULL;
+#endif
int i;
char key_buf[80]; /* must match size used by my_fgets80 */
@@ -952,7 +951,7 @@ int unzip_main(int argc, char **argv)
#if ENABLE_FEATURE_UNZIP_CDF
if (S_ISLNK(file_mode)) {
if (dst_fd != STDOUT_FILENO) /* not -p? */
- unzip_extract_symlink(&zip, dst_fn);
+ unzip_extract_symlink(&symlink_placeholders, &zip, dst_fn);
} else
#endif
{
@@ -988,6 +987,10 @@ int unzip_main(int argc, char **argv)
total_entries++;
}
+#if ENABLE_FEATURE_UNZIP_CDF
+ create_symlinks_from_list(symlink_placeholders);
+#endif
+
if ((opts & OPT_l) && quiet <= 1) {
if (!verbose) {
// " Length Date Time Name\n"