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)
343} 343}
344 344
345#if ENABLE_FEATURE_UNZIP_CDF 345#if ENABLE_FEATURE_UNZIP_CDF
346static void unzip_extract_symlink(zip_header_t *zip, const char *dst_fn) 346static void unzip_extract_symlink(llist_t **symlink_placeholders,
347 zip_header_t *zip,
348 const char *dst_fn)
347{ 349{
348 char *target; 350 char *target;
349 351
@@ -368,15 +370,9 @@ static void unzip_extract_symlink(zip_header_t *zip, const char *dst_fn)
368 target[xstate.mem_output_size] = '\0'; 370 target[xstate.mem_output_size] = '\0';
369#endif 371#endif
370 } 372 }
371 if (!unsafe_symlink_target(target)) { 373 create_or_remember_symlink(symlink_placeholders,
372//TODO: libbb candidate 374 target,
373 if (symlink(target, dst_fn)) { 375 dst_fn);
374 /* shared message */
375 bb_perror_msg_and_die("can't create %slink '%s' to '%s'",
376 "sym", dst_fn, target
377 );
378 }
379 }
380 free(target); 376 free(target);
381} 377}
382#endif 378#endif
@@ -488,6 +484,9 @@ int unzip_main(int argc, char **argv)
488 llist_t *zaccept = NULL; 484 llist_t *zaccept = NULL;
489 llist_t *zreject = NULL; 485 llist_t *zreject = NULL;
490 char *base_dir = NULL; 486 char *base_dir = NULL;
487#if ENABLE_FEATURE_UNZIP_CDF
488 llist_t *symlink_placeholders = NULL;
489#endif
491 int i; 490 int i;
492 char key_buf[80]; /* must match size used by my_fgets80 */ 491 char key_buf[80]; /* must match size used by my_fgets80 */
493 492
@@ -952,7 +951,7 @@ int unzip_main(int argc, char **argv)
952#if ENABLE_FEATURE_UNZIP_CDF 951#if ENABLE_FEATURE_UNZIP_CDF
953 if (S_ISLNK(file_mode)) { 952 if (S_ISLNK(file_mode)) {
954 if (dst_fd != STDOUT_FILENO) /* not -p? */ 953 if (dst_fd != STDOUT_FILENO) /* not -p? */
955 unzip_extract_symlink(&zip, dst_fn); 954 unzip_extract_symlink(&symlink_placeholders, &zip, dst_fn);
956 } else 955 } else
957#endif 956#endif
958 { 957 {
@@ -988,6 +987,10 @@ int unzip_main(int argc, char **argv)
988 total_entries++; 987 total_entries++;
989 } 988 }
990 989
990#if ENABLE_FEATURE_UNZIP_CDF
991 create_symlinks_from_list(symlink_placeholders);
992#endif
993
991 if ((opts & OPT_l) && quiet <= 1) { 994 if ((opts & OPT_l) && quiet <= 1) {
992 if (!verbose) { 995 if (!verbose) {
993 // " Length Date Time Name\n" 996 // " Length Date Time Name\n"