aboutsummaryrefslogtreecommitdiff
path: root/archival/unzip.c
AgeCommit message (Collapse)Author
2019-07-02libbb: reduce the overhead of single parameter bb_error_msg() callsJames Byrne
Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower overhead call to bb_perror_msg() when only a string was being printed with no parameters. This saves space for some CPU architectures because it avoids the overhead of a call to a variadic function. However there has never been a simple version of bb_error_msg(), and since 2007 many new calls to bb_perror_msg() have been added that only take a single parameter and so could have been using bb_simple_perror_message(). This changeset introduces 'simple' versions of bb_info_msg(), bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and bb_herror_msg_and_die(), and replaces all calls that only take a single parameter, or use something like ("%s", arg), with calls to the corresponding 'simple' version. Since it is likely that single parameter calls to the variadic functions may be accidentally reintroduced in the future a new debugging config option WARN_SIMPLE_MSG has been introduced. This uses some macro magic which will cause any such calls to generate a warning, but this is turned off by default to avoid use of the unpleasant macros in normal circumstances. This is a large changeset due to the number of calls that have been replaced. The only files that contain changes other than simple substitution of function calls are libbb.h, libbb/herror_msg.c, libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c, networking/udhcp/common.h and util-linux/mdev.c additonal macros have been added for logging so that single parameter and multiple parameter logging variants exist. The amount of space saved varies considerably by architecture, and was found to be as follows (for 'defconfig' using GCC 7.4): Arm: -92 bytes MIPS: -52 bytes PPC: -1836 bytes x86_64: -938 bytes Note that for the MIPS architecture only an exception had to be made disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h) because it made these files larger on MIPS. Signed-off-by: James Byrne <james.byrne@origamienergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-28config: update size informationDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-30unzip: use printable_string() for printing filenamesDenys Vlasenko
function old new delta unzip_main 2726 2792 +66 printable_string2 - 57 +57 identify 4329 4336 +7 expmeta 659 663 +4 add_interface 99 103 +4 beep_main 286 289 +3 changepath 192 194 +2 builtin_type 115 117 +2 devmem_main 469 470 +1 input_tab 1076 1074 -2 create_J 1821 1819 -2 poplocalvars 314 311 -3 doCommands 2222 2214 -8 do_load 918 902 -16 printable_string 57 9 -48 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 8/6 up/down: 146/-79) Total: 67 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-05-22tar: fix interaction of delayed symlink and hardlink creationHarald van Dijk
function old new delta create_or_remember_link - 106 +106 create_links_from_list - 93 +93 find_applet_by_name 124 128 +4 unzip_main 2724 2726 +2 data_extract_all 891 873 -18 create_symlinks_from_list 64 - -64 create_or_remember_symlink 94 - -94 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 2/1 up/down: 205/-176) Total: 29 bytes Signed-off-by: Harald van Dijk <harald@gigawatt.nl> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-20tar,unzip: postpone creation of symlinks with "suspicious" targetsDenys Vlasenko
This mostly reverts commit bc9bbeb2b81001e8731cd2ae501c8fccc8d87cc7 "libarchive: do not extract unsafe symlinks unless $EXTRACT_UNSAFE_SYMLINKS=1" Users report that it is somewhat too restrictive. See https://bugs.busybox.net/show_bug.cgi?id=8411 In particular, this interferes with unpacking of busybox-based filesystems with links like "sbin/applet" -> "../bin/busybox". The change is made smaller by deleting ARCHIVE_EXTRACT_QUIET flag - it is unused since 2010, and removing conditionals on it allows commonalizing some error message codes. function old new delta create_or_remember_symlink - 94 +94 create_symlinks_from_list - 64 +64 tar_main 1002 1006 +4 unzip_main 2732 2724 -8 data_extract_all 984 891 -93 unsafe_symlink_target 147 - -147 ------------------------------------------------------------------------------ (add/remove: 2/1 grow/shrink: 1/2 up/down: 162/-248) Total: -86 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-06unzip: do not set directory mode to 0777Denys Vlasenko
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=882177 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-11-09unzip: add missing -j to trivial usageEugene Rudoy
Signed-off-by: Eugene Rudoy <gene.devel@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-11-09unzip: fix content listing and filtering when -j is usedEugene Rudoy
Original Info-ZIP's unzip uses unstripped filenames while doing content listing and filtering, i.e. - in content listing mode -j is ignored completely - filtering is applied to non-stripped names, -j takes effect first while extracting the files 997ad2c64abbe931dffa3598b015c5de04e515cf strips path components a little bit too early resulting in behavior deviations. Fix it by doing stripping after listing/filtering. p.s. Info-ZIP's unzip behavior is the same as that of tar in --strip-components=NUM mode Signed-off-by: Eugene Rudoy <gene.devel@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-10libarchive: do not extract unsafe symlinks unless $EXTRACT_UNSAFE_SYMLINKS=1Denys Vlasenko
function old new delta unsafe_symlink_target - 147 +147 unzip_main 2711 2732 +21 copy_file 1657 1678 +21 tar_main 999 971 -28 data_extract_all 1038 984 -54 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 2/2 up/down: 189/-82) Total: 107 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-27unzip: fix regression on big-endian machinesNatanael Copa
This fixes a regression which was introduced with commit 2a0867a5 ("unzip: optional support for bzip2 and lzma") and causes unzip to exit with error when extracting archives: unzip: unsupported method 2048 Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-21config: deindent all help textsDenys Vlasenko
Those two spaces after tab have no effect, and always a nuisance when editing. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-20unzip: sanitize filename length: malloc(1234mb) is not funnyDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-20unzip: implement -j, closes 9126Denys Vlasenko
function old new delta unzip_main 2642 2703 +61 packed_usage 31747 31770 +23 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 84/0) Total: 84 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-20unzip: robustify overwrite checksDenys Vlasenko
function old new delta get_lstat_mode - 55 +55 unzip_main 2667 2642 -25 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 55/-25) Total: 30 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-20unzip: support symlinks. Closes 10031Denys Vlasenko
function old new delta unzip_main 2519 2667 +148 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-18Update menuconfig items with approximate applet sizesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-11unzip: TODO for symlink supportDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-03-24whitespace fixDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-09unzip: match "Defl:?" display with info-zip; cosmetic code shufflingDenys Vlasenko
Large nested indented code blocks made more sane with a few gotos. function old new delta unzip_main 2491 2519 +28 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-09unzip: optional support for xzDenys Vlasenko
function old new delta unzip_main 2476 2491 +15 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-09unzip: optional support for bzip2 and lzmaDenys Vlasenko
function old new delta unzip_main 2376 2476 +100 bbunpack 750 745 -5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-08unzip: do not use CDF.extra_len, read local file header. Closes 9536Denys Vlasenko
While at it, shorten many field and variable names. function old new delta unzip_main 2334 2376 +42 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-05unzip: remove now-pointless lseek which returns current positionCristian Ionescu-Idbohrn
archival/unzip.c: In function 'read_next_cdf': archival/unzip.c:271:8: warning: variable 'org' set but not used [-Wunused-but-set-variable] off_t org; ^~~ Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-05typo fix in config help textDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-05unzip: properly use CDF to find compressed files. Closes 9536Denys Vlasenko
function old new delta unzip_main 2437 2350 -87 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-22*: slap on a few ALIGN1/2s where appropriateDenys Vlasenko
The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map" text data bss dec hex filename 829901 4086 1904 835891 cc133 busybox_before 829665 4086 1904 835655 cc047 busybox Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-18unzip: shorter code for date/time generationDenys Vlasenko
function old new delta unzip_main 2426 2414 -12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-18unzip: better match for "standard" unzip's output; string shrinkageDenys Vlasenko
function old new delta unzip_main 2490 2426 -64 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-64) Total: -64 bytes text data bss dec hex filename 924008 906 17160 942074 e5ffa busybox_old 923846 906 17160 941912 e5f58 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-18unzip: fix percent overflow; show "stored" files properlyDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-17unzip: fix a case where we find wrong CDE. Closes 8821Denys Vlasenko
function old new delta unzip_main 2472 2490 +18 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-13Removes stray empty line from codeManinder Singh
This patch removes stray empty line from busybox code reported by script find_stray_empty_lines Signed-off-by: Maninder Singh <maninder1.s@samsung.com> Signed-off-by: Akhilesh Kumar <akhilesh.k@samsung.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-10unzip: prevent attacks via malicious filenamesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-07libarchive: add capability to unpack to mem.bufferDenys Vlasenko
The performance and number of processes for a "depmod -a" with gzipped modules was abysmal. This patch adds a code path without fork, benefiting all users of xmalloc_open_zipped_read_close. "modinfo radeon.ko.gz", a single-file reader, got 30% faster. "depmod -a", which used to fork over 800 times, got 20% faster. Heavily based on a patch by Lauri Kasanen <curaga@operamail.com> function old new delta setup_transformer_on_fd - 159 +159 transformer_write - 122 +122 fork_transformer - 112 +112 xmalloc_open_zipped_read_close 63 118 +55 read_bunzip 1866 1896 +30 xtransformer_write - 19 +19 unzip_main 2449 2462 +13 bbunpack 755 766 +11 unpack_lzma_stream 2717 2723 +6 unpack_xz_stream 2393 2397 +4 unpack_Z_stream 1173 1175 +2 inflate_unzip 111 105 -6 check_signature16 70 63 -7 unpack_bz2_stream 359 349 -10 unpack_unxz 12 - -12 unpack_unlzma 12 - -12 unpack_uncompress 12 - -12 unpack_gunzip 12 - -12 unpack_bunzip2 12 - -12 open_transformer 106 92 -14 inflate_unzip_internal 1945 1916 -29 unpack_gz_stream 693 655 -38 open_zipped 89 47 -42 setup_unzip_on_fd 142 53 -89 ------------------------------------------------------------------------------ (add/remove: 4/5 grow/shrink: 7/8 up/down: 533/-295) Total: 238 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-07Rename transformer_aux_data_t -> transformer_state_tDenys Vlasenko
No code changes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-14archival/*: move "config:" snippets into .c filesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-14archival/*: move "applet:" snippets into .c files, part 2Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-14archival/*: move "kbuild:" snippets into .c filesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-21unzip: survive lack of CDF on non-streaming zip filesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-20unzip: increase PEEK_FROM_END from 16k to 64kDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-22unzip: add missing fflush; code shrinkDenys Vlasenko
function old new delta my_fgets80 - 41 +41 unzip_main 2291 2242 -49 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-22*: reuse more stringsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-19tweak help textDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-15unzip: make options parsing more robust on getopt w/o gnu extensionsDenys Vlasenko
Also, code shrank: function old new delta static.extn 15 10 -5 packed_usage 29231 29217 -14 unzip_main 2388 2291 -97 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-116) Total: -116 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-28unzip: ignore chmod errorsNatanael Copa
This makes unzip to FAT filesystems not exit with error. This is similar to how the "normal" unzip works. Signed-off-by: Natanael Copa <natanael.copa@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-06update seamless uncompression codeDenys Vlasenko
This change makes "tar tf hello_world.txz" work without adding special-casing for ".txz" extension. It also removes ever-growing magic checking code in rpm2cpio and get_header_tar - we reuse one which lives in setup_unzip_on_fd. function old new delta unpack_gz_stream 7 566 +559 check_signature16 - 70 +70 setup_unzip_on_fd 99 142 +43 handle_SIGCHLD - 41 +41 unpack_bz2_stream 342 376 +34 unzip_main 2352 2385 +33 bbunpack 503 533 +30 open_transformer 74 102 +28 unpack_Z_stream 1278 1304 +26 unpack_gunzip 101 123 +22 init_transformer_aux_data - 18 +18 unpack_xz_stream 2388 2402 +14 open_zipped 131 141 +10 rpm_main 1358 1363 +5 get_header_tar_lzma 52 57 +5 get_header_tar_bz2 52 57 +5 unpack_lzma_stream 2698 2702 +4 hash_find 234 233 -1 get_header_tar 1759 1733 -26 get_header_tar_gz 92 57 -35 unpack_uncompress 51 12 -39 rpm2cpio_main 201 147 -54 unpack_unxz 67 12 -55 unpack_bz2_stream_prime 55 - -55 get_header_tar_Z 86 - -86 unpack_gz_stream_with_info 539 - -539 ------------------------------------------------------------------------------ (add/remove: 3/3 grow/shrink: 14/6 up/down: 947/-890) Total: 57 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-22rename archive.h to bb_archive.h. no code changesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-09unzip: fflush stdout before reading interative y/n answer from stdinDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-05*: remove "Options:" string from help textsDenys Vlasenko
function old new delta packed_usage 28706 28623 -83 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-27move help text from include/usage.src.h to archival/*.cPere Orga
Signed-off-by: Pere Orga <gotrunks@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-11-03rename archival/libunarchive -> archival/libarchive; move bz/ into itDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>