diff options
Diffstat (limited to 'archival')
-rw-r--r-- | archival/cpio.c | 2 | ||||
-rw-r--r-- | archival/libarchive/data_extract_all.c | 16 | ||||
-rw-r--r-- | archival/libarchive/get_header_ar.c | 2 | ||||
-rw-r--r-- | archival/libarchive/unsafe_symlink_target.c | 21 | ||||
-rw-r--r-- | archival/tar.c | 2 | ||||
-rw-r--r-- | archival/unzip.c | 7 |
6 files changed, 25 insertions, 25 deletions
diff --git a/archival/cpio.c b/archival/cpio.c index 308ec1b25..221667112 100644 --- a/archival/cpio.c +++ b/archival/cpio.c | |||
@@ -508,7 +508,7 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
508 | while (get_header_cpio(archive_handle) == EXIT_SUCCESS) | 508 | while (get_header_cpio(archive_handle) == EXIT_SUCCESS) |
509 | continue; | 509 | continue; |
510 | 510 | ||
511 | create_symlinks_from_list(archive_handle->symlink_placeholders); | 511 | create_links_from_list(archive_handle->link_placeholders); |
512 | 512 | ||
513 | if (archive_handle->cpio__blocks != (off_t)-1 | 513 | if (archive_handle->cpio__blocks != (off_t)-1 |
514 | && !(opt & OPT_QUIET) | 514 | && !(opt & OPT_QUIET) |
diff --git a/archival/libarchive/data_extract_all.c b/archival/libarchive/data_extract_all.c index 8fa69ffaf..4c95db4a6 100644 --- a/archival/libarchive/data_extract_all.c +++ b/archival/libarchive/data_extract_all.c | |||
@@ -122,13 +122,10 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) | |||
122 | 122 | ||
123 | /* Handle hard links separately */ | 123 | /* Handle hard links separately */ |
124 | if (hard_link) { | 124 | if (hard_link) { |
125 | res = link(hard_link, dst_name); | 125 | create_or_remember_link(&archive_handle->link_placeholders, |
126 | if (res != 0) { | 126 | hard_link, |
127 | /* shared message */ | 127 | dst_name, |
128 | bb_perror_msg("can't create %slink '%s' to '%s'", | 128 | 1); |
129 | "hard", dst_name, hard_link | ||
130 | ); | ||
131 | } | ||
132 | /* Hardlinks have no separate mode/ownership, skip chown/chmod */ | 129 | /* Hardlinks have no separate mode/ownership, skip chown/chmod */ |
133 | goto ret; | 130 | goto ret; |
134 | } | 131 | } |
@@ -195,9 +192,10 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) | |||
195 | * | 192 | * |
196 | * Untarring bug.tar would otherwise place evil.py in '/tmp'. | 193 | * Untarring bug.tar would otherwise place evil.py in '/tmp'. |
197 | */ | 194 | */ |
198 | create_or_remember_symlink(&archive_handle->symlink_placeholders, | 195 | create_or_remember_link(&archive_handle->link_placeholders, |
199 | file_header->link_target, | 196 | file_header->link_target, |
200 | dst_name); | 197 | dst_name, |
198 | 0); | ||
201 | break; | 199 | break; |
202 | case S_IFSOCK: | 200 | case S_IFSOCK: |
203 | case S_IFBLK: | 201 | case S_IFBLK: |
diff --git a/archival/libarchive/get_header_ar.c b/archival/libarchive/get_header_ar.c index adcde46d5..7ce9c615c 100644 --- a/archival/libarchive/get_header_ar.c +++ b/archival/libarchive/get_header_ar.c | |||
@@ -126,7 +126,7 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle) | |||
126 | struct archive_handle_t *sa = archive_handle->dpkg__sub_archive; | 126 | struct archive_handle_t *sa = archive_handle->dpkg__sub_archive; |
127 | while (archive_handle->dpkg__action_data_subarchive(sa) == EXIT_SUCCESS) | 127 | while (archive_handle->dpkg__action_data_subarchive(sa) == EXIT_SUCCESS) |
128 | continue; | 128 | continue; |
129 | create_symlinks_from_list(sa->symlink_placeholders); | 129 | create_links_from_list(sa->link_placeholders); |
130 | } else | 130 | } else |
131 | #endif | 131 | #endif |
132 | archive_handle->action_data(archive_handle); | 132 | archive_handle->action_data(archive_handle); |
diff --git a/archival/libarchive/unsafe_symlink_target.c b/archival/libarchive/unsafe_symlink_target.c index 8dcafeaa1..f8dc8033d 100644 --- a/archival/libarchive/unsafe_symlink_target.c +++ b/archival/libarchive/unsafe_symlink_target.c | |||
@@ -5,13 +5,14 @@ | |||
5 | #include "libbb.h" | 5 | #include "libbb.h" |
6 | #include "bb_archive.h" | 6 | #include "bb_archive.h" |
7 | 7 | ||
8 | void FAST_FUNC create_or_remember_symlink(llist_t **symlink_placeholders, | 8 | void FAST_FUNC create_or_remember_link(llist_t **link_placeholders, |
9 | const char *target, | 9 | const char *target, |
10 | const char *linkname) | 10 | const char *linkname, |
11 | int hard_link) | ||
11 | { | 12 | { |
12 | if (target[0] == '/' || strstr(target, "..")) { | 13 | if (hard_link || target[0] == '/' || strstr(target, "..")) { |
13 | llist_add_to(symlink_placeholders, | 14 | llist_add_to_end(link_placeholders, |
14 | xasprintf("%s%c%s", linkname, '\0', target) | 15 | xasprintf("%c%s%c%s", hard_link, linkname, '\0', target) |
15 | ); | 16 | ); |
16 | return; | 17 | return; |
17 | } | 18 | } |
@@ -23,17 +24,17 @@ void FAST_FUNC create_or_remember_symlink(llist_t **symlink_placeholders, | |||
23 | } | 24 | } |
24 | } | 25 | } |
25 | 26 | ||
26 | void FAST_FUNC create_symlinks_from_list(llist_t *list) | 27 | void FAST_FUNC create_links_from_list(llist_t *list) |
27 | { | 28 | { |
28 | while (list) { | 29 | while (list) { |
29 | char *target; | 30 | char *target; |
30 | 31 | ||
31 | target = list->data + strlen(list->data) + 1; | 32 | target = list->data + 1 + strlen(list->data + 1) + 1; |
32 | if (symlink(target, list->data)) { | 33 | if ((*list->data ? link : symlink) (target, list->data + 1)) { |
33 | /* shared message */ | 34 | /* shared message */ |
34 | bb_error_msg_and_die("can't create %slink '%s' to '%s'", | 35 | bb_error_msg_and_die("can't create %slink '%s' to '%s'", |
35 | "sym", | 36 | *list->data ? "hard" : "sym", |
36 | list->data, target | 37 | list->data + 1, target |
37 | ); | 38 | ); |
38 | } | 39 | } |
39 | list = list->link; | 40 | list = list->link; |
diff --git a/archival/tar.c b/archival/tar.c index a8b888fa9..ae1ccc756 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -1244,7 +1244,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
1244 | while (get_header_tar(tar_handle) == EXIT_SUCCESS) | 1244 | while (get_header_tar(tar_handle) == EXIT_SUCCESS) |
1245 | bb_got_signal = EXIT_SUCCESS; /* saw at least one header, good */ | 1245 | bb_got_signal = EXIT_SUCCESS; /* saw at least one header, good */ |
1246 | 1246 | ||
1247 | create_symlinks_from_list(tar_handle->symlink_placeholders); | 1247 | create_links_from_list(tar_handle->link_placeholders); |
1248 | 1248 | ||
1249 | /* Check that every file that should have been extracted was */ | 1249 | /* Check that every file that should have been extracted was */ |
1250 | while (tar_handle->accept) { | 1250 | while (tar_handle->accept) { |
diff --git a/archival/unzip.c b/archival/unzip.c index 0d00d8dc9..96b7ab69b 100644 --- a/archival/unzip.c +++ b/archival/unzip.c | |||
@@ -372,9 +372,10 @@ static void unzip_extract_symlink(llist_t **symlink_placeholders, | |||
372 | target[xstate.mem_output_size] = '\0'; | 372 | target[xstate.mem_output_size] = '\0'; |
373 | #endif | 373 | #endif |
374 | } | 374 | } |
375 | create_or_remember_symlink(symlink_placeholders, | 375 | create_or_remember_link(symlink_placeholders, |
376 | target, | 376 | target, |
377 | dst_fn); | 377 | dst_fn, |
378 | 0); | ||
378 | free(target); | 379 | free(target); |
379 | } | 380 | } |
380 | #endif | 381 | #endif |
@@ -990,7 +991,7 @@ int unzip_main(int argc, char **argv) | |||
990 | } | 991 | } |
991 | 992 | ||
992 | #if ENABLE_FEATURE_UNZIP_CDF | 993 | #if ENABLE_FEATURE_UNZIP_CDF |
993 | create_symlinks_from_list(symlink_placeholders); | 994 | create_links_from_list(symlink_placeholders); |
994 | #endif | 995 | #endif |
995 | 996 | ||
996 | if ((opts & OPT_l) && quiet <= 1) { | 997 | if ((opts & OPT_l) && quiet <= 1) { |