diff options
Diffstat (limited to 'archival/unzip.c')
-rw-r--r-- | archival/unzip.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/archival/unzip.c b/archival/unzip.c index da4b2a544..0d00d8dc9 100644 --- a/archival/unzip.c +++ b/archival/unzip.c | |||
@@ -345,7 +345,9 @@ static void unzip_create_leading_dirs(const char *fn) | |||
345 | } | 345 | } |
346 | 346 | ||
347 | #if ENABLE_FEATURE_UNZIP_CDF | 347 | #if ENABLE_FEATURE_UNZIP_CDF |
348 | static void unzip_extract_symlink(zip_header_t *zip, const char *dst_fn) | 348 | static void unzip_extract_symlink(llist_t **symlink_placeholders, |
349 | zip_header_t *zip, | ||
350 | const char *dst_fn) | ||
349 | { | 351 | { |
350 | char *target; | 352 | char *target; |
351 | 353 | ||
@@ -370,15 +372,9 @@ static void unzip_extract_symlink(zip_header_t *zip, const char *dst_fn) | |||
370 | target[xstate.mem_output_size] = '\0'; | 372 | target[xstate.mem_output_size] = '\0'; |
371 | #endif | 373 | #endif |
372 | } | 374 | } |
373 | if (!unsafe_symlink_target(target)) { | 375 | create_or_remember_symlink(symlink_placeholders, |
374 | //TODO: libbb candidate | 376 | target, |
375 | if (symlink(target, dst_fn)) { | 377 | dst_fn); |
376 | /* shared message */ | ||
377 | bb_perror_msg_and_die("can't create %slink '%s' to '%s'", | ||
378 | "sym", dst_fn, target | ||
379 | ); | ||
380 | } | ||
381 | } | ||
382 | free(target); | 378 | free(target); |
383 | } | 379 | } |
384 | #endif | 380 | #endif |
@@ -490,6 +486,9 @@ int unzip_main(int argc, char **argv) | |||
490 | llist_t *zaccept = NULL; | 486 | llist_t *zaccept = NULL; |
491 | llist_t *zreject = NULL; | 487 | llist_t *zreject = NULL; |
492 | char *base_dir = NULL; | 488 | char *base_dir = NULL; |
489 | #if ENABLE_FEATURE_UNZIP_CDF | ||
490 | llist_t *symlink_placeholders = NULL; | ||
491 | #endif | ||
493 | int i; | 492 | int i; |
494 | char key_buf[80]; /* must match size used by my_fgets80 */ | 493 | char key_buf[80]; /* must match size used by my_fgets80 */ |
495 | 494 | ||
@@ -954,7 +953,7 @@ int unzip_main(int argc, char **argv) | |||
954 | #if ENABLE_FEATURE_UNZIP_CDF | 953 | #if ENABLE_FEATURE_UNZIP_CDF |
955 | if (S_ISLNK(file_mode)) { | 954 | if (S_ISLNK(file_mode)) { |
956 | if (dst_fd != STDOUT_FILENO) /* not -p? */ | 955 | if (dst_fd != STDOUT_FILENO) /* not -p? */ |
957 | unzip_extract_symlink(&zip, dst_fn); | 956 | unzip_extract_symlink(&symlink_placeholders, &zip, dst_fn); |
958 | } else | 957 | } else |
959 | #endif | 958 | #endif |
960 | { | 959 | { |
@@ -990,6 +989,10 @@ int unzip_main(int argc, char **argv) | |||
990 | total_entries++; | 989 | total_entries++; |
991 | } | 990 | } |
992 | 991 | ||
992 | #if ENABLE_FEATURE_UNZIP_CDF | ||
993 | create_symlinks_from_list(symlink_placeholders); | ||
994 | #endif | ||
995 | |||
993 | if ((opts & OPT_l) && quiet <= 1) { | 996 | if ((opts & OPT_l) && quiet <= 1) { |
994 | if (!verbose) { | 997 | if (!verbose) { |
995 | // " Length Date Time Name\n" | 998 | // " Length Date Time Name\n" |