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 fb58b62c0..369c6c028 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -348,7 +348,9 @@ static void unzip_create_leading_dirs(const char *fn)
348} 348}
349 349
350#if ENABLE_FEATURE_UNZIP_CDF 350#if ENABLE_FEATURE_UNZIP_CDF
351static void unzip_extract_symlink(zip_header_t *zip, const char *dst_fn) 351static void unzip_extract_symlink(llist_t **symlink_placeholders,
352 zip_header_t *zip,
353 const char *dst_fn)
352{ 354{
353 char *target; 355 char *target;
354 356
@@ -373,15 +375,9 @@ static void unzip_extract_symlink(zip_header_t *zip, const char *dst_fn)
373 target[xstate.mem_output_size] = '\0'; 375 target[xstate.mem_output_size] = '\0';
374#endif 376#endif
375 } 377 }
376 if (!unsafe_symlink_target(target)) { 378 create_or_remember_symlink(symlink_placeholders,
377//TODO: libbb candidate 379 target,
378 if (symlink(target, dst_fn)) { 380 dst_fn);
379 /* shared message */
380 bb_perror_msg_and_die("can't create %slink '%s' to '%s'",
381 "sym", dst_fn, target
382 );
383 }
384 }
385 free(target); 381 free(target);
386} 382}
387#endif 383#endif
@@ -493,6 +489,9 @@ int unzip_main(int argc, char **argv)
493 llist_t *zaccept = NULL; 489 llist_t *zaccept = NULL;
494 llist_t *zreject = NULL; 490 llist_t *zreject = NULL;
495 char *base_dir = NULL; 491 char *base_dir = NULL;
492#if ENABLE_FEATURE_UNZIP_CDF
493 llist_t *symlink_placeholders = NULL;
494#endif
496 int i; 495 int i;
497 char key_buf[80]; /* must match size used by my_fgets80 */ 496 char key_buf[80]; /* must match size used by my_fgets80 */
498 497
@@ -957,7 +956,7 @@ int unzip_main(int argc, char **argv)
957#if ENABLE_FEATURE_UNZIP_CDF 956#if ENABLE_FEATURE_UNZIP_CDF
958 if (S_ISLNK(file_mode)) { 957 if (S_ISLNK(file_mode)) {
959 if (dst_fd != STDOUT_FILENO) /* not -p? */ 958 if (dst_fd != STDOUT_FILENO) /* not -p? */
960 unzip_extract_symlink(&zip, dst_fn); 959 unzip_extract_symlink(&symlink_placeholders, &zip, dst_fn);
961 } else 960 } else
962#endif 961#endif
963 { 962 {
@@ -993,6 +992,10 @@ int unzip_main(int argc, char **argv)
993 total_entries++; 992 total_entries++;
994 } 993 }
995 994
995#if ENABLE_FEATURE_UNZIP_CDF
996 create_symlinks_from_list(symlink_placeholders);
997#endif
998
996 if ((opts & OPT_l) && quiet <= 1) { 999 if ((opts & OPT_l) && quiet <= 1) {
997 if (!verbose) { 1000 if (!verbose) {
998 // " Length Date Time Name\n" 1001 // " Length Date Time Name\n"