aboutsummaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-07-25 10:41:42 +0100
committerRon Yorston <rmy@pobox.com>2018-07-25 10:41:42 +0100
commit59873514f17cefd6ba3997dad5779f75433fd4e6 (patch)
tree1c9d0a3450ed95f0b820285b9f9fc217c902e652 /archival
parent779fd5745ac11bf752f5f4b977a274a39c192f90 (diff)
parent81de30de05beebabfa72f2a01ec4f33e9a1923e3 (diff)
downloadbusybox-w32-59873514f17cefd6ba3997dad5779f75433fd4e6.tar.gz
busybox-w32-59873514f17cefd6ba3997dad5779f75433fd4e6.tar.bz2
busybox-w32-59873514f17cefd6ba3997dad5779f75433fd4e6.zip
Merge branch 'busybox'
Diffstat (limited to 'archival')
-rw-r--r--archival/Config.src2
-rw-r--r--archival/cpio.c11
-rw-r--r--archival/gzip.c12
-rw-r--r--archival/libarchive/data_extract_all.c16
-rw-r--r--archival/libarchive/decompress_unlzma.c6
-rw-r--r--archival/libarchive/get_header_ar.c2
-rw-r--r--archival/libarchive/unsafe_symlink_target.c21
-rw-r--r--archival/tar.c2
-rw-r--r--archival/unzip.c7
9 files changed, 43 insertions, 36 deletions
diff --git a/archival/Config.src b/archival/Config.src
index 449914565..6f4f30c43 100644
--- a/archival/Config.src
+++ b/archival/Config.src
@@ -1,6 +1,6 @@
1# 1#
2# For a description of the syntax of this configuration file, 2# For a description of the syntax of this configuration file,
3# see scripts/kbuild/config-language.txt. 3# see docs/Kconfig-language.txt.
4# 4#
5 5
6menu "Archival Utilities" 6menu "Archival Utilities"
diff --git a/archival/cpio.c b/archival/cpio.c
index 308ec1b25..9cacf9de6 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -64,15 +64,17 @@
64//usage: "\n -p DIR Copy files to DIR" 64//usage: "\n -p DIR Copy files to DIR"
65//usage: ) 65//usage: )
66//usage: "\nOptions:" 66//usage: "\nOptions:"
67//usage: IF_FEATURE_CPIO_O(
68//usage: "\n -H newc Archive format"
69//usage: )
67//usage: "\n -d Make leading directories" 70//usage: "\n -d Make leading directories"
68//usage: "\n -m Preserve mtime" 71//usage: "\n -m Preserve mtime"
69//usage: "\n -v Verbose" 72//usage: "\n -v Verbose"
70//usage: "\n -u Overwrite" 73//usage: "\n -u Overwrite"
71//usage: "\n -F FILE Input (-t,-i,-p) or output (-o) file" 74//usage: "\n -F FILE Input (-t,-i,-p) or output (-o) file"
72//usage: "\n -R USER[:GRP] Set owner of created files" 75//usage: "\n -R USER[:GRP] Set owner of created files"
73//usage: IF_FEATURE_CPIO_O( 76//usage: "\n -L Dereference symlinks"
74//usage: "\n -H newc Archive format" 77//usage: "\n -0 Input is separated by NULs"
75//usage: )
76 78
77/* GNU cpio 2.9 --help (abridged): 79/* GNU cpio 2.9 --help (abridged):
78 80
@@ -374,6 +376,7 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
374#endif 376#endif
375 "owner\0" Required_argument "R" 377 "owner\0" Required_argument "R"
376 "verbose\0" No_argument "v" 378 "verbose\0" No_argument "v"
379 "null\0" No_argument "0"
377 "quiet\0" No_argument "\xff" 380 "quiet\0" No_argument "\xff"
378 "to-stdout\0" No_argument "\xfe" 381 "to-stdout\0" No_argument "\xfe"
379 ; 382 ;
@@ -508,7 +511,7 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
508 while (get_header_cpio(archive_handle) == EXIT_SUCCESS) 511 while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
509 continue; 512 continue;
510 513
511 create_symlinks_from_list(archive_handle->symlink_placeholders); 514 create_links_from_list(archive_handle->link_placeholders);
512 515
513 if (archive_handle->cpio__blocks != (off_t)-1 516 if (archive_handle->cpio__blocks != (off_t)-1
514 && !(opt & OPT_QUIET) 517 && !(opt & OPT_QUIET)
diff --git a/archival/gzip.c b/archival/gzip.c
index c5a1fe9b4..74d5d685f 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -333,12 +333,6 @@ struct globals {
333 /* DECLARE(Pos, head, 1<<HASH_BITS); */ 333 /* DECLARE(Pos, head, 1<<HASH_BITS); */
334#define head (G1.prev + WSIZE) /* hash head (see deflate.c) */ 334#define head (G1.prev + WSIZE) /* hash head (see deflate.c) */
335 335
336/* =========================================================================== */
337/* all members below are zeroed out in pack_gzip() for each next file */
338
339 uint32_t crc; /* shift register contents */
340 /*uint32_t *crc_32_tab;*/
341
342#if ENABLE_FEATURE_GZIP_LEVELS 336#if ENABLE_FEATURE_GZIP_LEVELS
343 unsigned max_chain_length; 337 unsigned max_chain_length;
344 unsigned max_lazy_match; 338 unsigned max_lazy_match;
@@ -350,6 +344,12 @@ struct globals {
350#define nice_match (G1.nice_match) 344#define nice_match (G1.nice_match)
351#endif 345#endif
352 346
347/* =========================================================================== */
348/* all members below are zeroed out in pack_gzip() for each next file */
349
350 uint32_t crc; /* shift register contents */
351 /*uint32_t *crc_32_tab;*/
352
353/* window position at the beginning of the current output block. Gets 353/* window position at the beginning of the current output block. Gets
354 * negative when the window is moved backwards. 354 * negative when the window is moved backwards.
355 */ 355 */
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/decompress_unlzma.c b/archival/libarchive/decompress_unlzma.c
index 446319e7b..6886239d0 100644
--- a/archival/libarchive/decompress_unlzma.c
+++ b/archival/libarchive/decompress_unlzma.c
@@ -350,8 +350,12 @@ unpack_lzma_stream(transformer_state_t *xstate)
350 state = state < LZMA_NUM_LIT_STATES ? 9 : 11; 350 state = state < LZMA_NUM_LIT_STATES ? 9 : 11;
351 351
352 pos = buffer_pos - rep0; 352 pos = buffer_pos - rep0;
353 if ((int32_t)pos < 0) 353 if ((int32_t)pos < 0) {
354 pos += header.dict_size; 354 pos += header.dict_size;
355 /* see unzip_bad_lzma_2.zip: */
356 if (pos >= buffer_size)
357 goto bad;
358 }
355 previous_byte = buffer[pos]; 359 previous_byte = buffer[pos];
356 goto one_byte1; 360 goto one_byte1;
357#else 361#else
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 0ad4c9392..f53881f2f 100644
--- a/archival/libarchive/unsafe_symlink_target.c
+++ b/archival/libarchive/unsafe_symlink_target.c
@@ -5,15 +5,16 @@
5#include "libbb.h" 5#include "libbb.h"
6#include "bb_archive.h" 6#include "bb_archive.h"
7 7
8void FAST_FUNC create_or_remember_symlink(llist_t **symlink_placeholders 8void FAST_FUNC create_or_remember_link(llist_t **link_placeholders
9 IF_PLATFORM_MINGW32(UNUSED_PARAM), 9 IF_PLATFORM_MINGW32(UNUSED_PARAM),
10 const char *target, 10 const char *target,
11 const char *linkname) 11 const char *linkname,
12 int hard_link IF_PLATFORM_MINGW32(UNUSED_PARAM))
12{ 13{
13#if !ENABLE_PLATFORM_MINGW32 14#if !ENABLE_PLATFORM_MINGW32
14 if (target[0] == '/' || strstr(target, "..")) { 15 if (hard_link || target[0] == '/' || strstr(target, "..")) {
15 llist_add_to(symlink_placeholders, 16 llist_add_to_end(link_placeholders,
16 xasprintf("%s%c%s", linkname, '\0', target) 17 xasprintf("%c%s%c%s", hard_link, linkname, '\0', target)
17 ); 18 );
18 return; 19 return;
19 } 20 }
@@ -30,17 +31,17 @@ void FAST_FUNC create_or_remember_symlink(llist_t **symlink_placeholders
30} 31}
31 32
32#if !ENABLE_PLATFORM_MINGW32 33#if !ENABLE_PLATFORM_MINGW32
33void FAST_FUNC create_symlinks_from_list(llist_t *list) 34void FAST_FUNC create_links_from_list(llist_t *list)
34{ 35{
35 while (list) { 36 while (list) {
36 char *target; 37 char *target;
37 38
38 target = list->data + strlen(list->data) + 1; 39 target = list->data + 1 + strlen(list->data + 1) + 1;
39 if (symlink(target, list->data)) { 40 if ((*list->data ? link : symlink) (target, list->data + 1)) {
40 /* shared message */ 41 /* shared message */
41 bb_error_msg_and_die("can't create %slink '%s' to '%s'", 42 bb_error_msg_and_die("can't create %slink '%s' to '%s'",
42 "sym", 43 *list->data ? "hard" : "sym",
43 list->data, target 44 list->data + 1, target
44 ); 45 );
45 } 46 }
46 list = list->link; 47 list = list->link;
diff --git a/archival/tar.c b/archival/tar.c
index afd8cfec5..e1af27401 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -1279,7 +1279,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
1279 while (get_header_tar(tar_handle) == EXIT_SUCCESS) 1279 while (get_header_tar(tar_handle) == EXIT_SUCCESS)
1280 bb_got_signal = EXIT_SUCCESS; /* saw at least one header, good */ 1280 bb_got_signal = EXIT_SUCCESS; /* saw at least one header, good */
1281 1281
1282 create_symlinks_from_list(tar_handle->symlink_placeholders); 1282 create_links_from_list(tar_handle->link_placeholders);
1283 1283
1284 /* Check that every file that should have been extracted was */ 1284 /* Check that every file that should have been extracted was */
1285 while (tar_handle->accept) { 1285 while (tar_handle->accept) {
diff --git a/archival/unzip.c b/archival/unzip.c
index 369c6c028..a9b7dc10f 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -375,9 +375,10 @@ static void unzip_extract_symlink(llist_t **symlink_placeholders,
375 target[xstate.mem_output_size] = '\0'; 375 target[xstate.mem_output_size] = '\0';
376#endif 376#endif
377 } 377 }
378 create_or_remember_symlink(symlink_placeholders, 378 create_or_remember_link(symlink_placeholders,
379 target, 379 target,
380 dst_fn); 380 dst_fn,
381 0);
381 free(target); 382 free(target);
382} 383}
383#endif 384#endif
@@ -993,7 +994,7 @@ int unzip_main(int argc, char **argv)
993 } 994 }
994 995
995#if ENABLE_FEATURE_UNZIP_CDF 996#if ENABLE_FEATURE_UNZIP_CDF
996 create_symlinks_from_list(symlink_placeholders); 997 create_links_from_list(symlink_placeholders);
997#endif 998#endif
998 999
999 if ((opts & OPT_l) && quiet <= 1) { 1000 if ((opts & OPT_l) && quiet <= 1) {