aboutsummaryrefslogtreecommitdiff
path: root/archival/libarchive
Commit message (Collapse)AuthorAgeFilesLines
* cpio: fix sscanf on unterminated bufferGravatar S Harris40 hours1-1/+2
| | | | | Signed-off-by: S Harris <S.E.Harris@kent.ac.uk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* unlzma: fix a case where we could read before beginning of bufferGravatar Denys Vlasenko10 days1-1/+4
| | | | | | | | | | | | | | | Testcase: 21 01 01 00 00 00 00 00 e7 01 01 01 ef 00 df b6 00 17 02 10 11 0f ff 00 16 00 00 Unfortunately, the bug is not reliably causing a segfault, the behavior depends on what's in memory before the buffer. function old new delta unpack_lzma_stream 2762 2768 +6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* decompress_gunzip: simplify ERR_RET bit clearingGravatar Denys Vlasenko2021-05-031-3/+2
| | | | | | My gcc is in fact clever enough to do it itself, but let's be explicit Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* decompress_gunzip: Fix DoS if gzip is corruptGravatar Samuel Sapalski2021-03-121-2/+10
| | | | | | | | | | | | | | On certain corrupt gzip files, huft_build will set the error bit on the result pointer. If afterwards abort_unzip is called huft_free might run into a segmentation fault or an invalid pointer to free(p). In order to mitigate this, we check in huft_free if the error bit is set and clear it before the linked list is freed. Signed-off-by: Samuel Sapalski <samuel.sapalski@nokia.com> Signed-off-by: Peter Kaestle <peter.kaestle@nokia.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* tar: add TODO about a bug with non-writable directories on extractGravatar Denys Vlasenko2021-01-011-0/+4
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* decrease padding: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nillyGravatar Denys Vlasenko2020-11-301-2/+2
| | | | | | | | text data bss dec hex filename 1021236 559 5052 1026847 fab1f busybox_old 1021120 559 5052 1026731 faaab busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* decrease paddign: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nillyGravatar Denys Vlasenko2020-11-302-2/+2
| | | | | | | | text data bss dec hex filename 1021988 559 5052 1027599 fae0f busybox_old 1021236 559 5052 1026847 fab1f busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* archival: avoid std namespace for local includesGravatar Joachim Nilsson2020-11-162-2/+2
| | | | | | | | Avoid using same include file naming pattern as available in GLIBC. Renamed to match grp_.h et al. Signed-off-by: Joachim Nilsson <troglobit@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* tar: fix fallout of last_char_is(NULL) no longer being allowedGravatar Denys Vlasenko2020-10-021-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* gunzip: fix incorrect decoding of "fixed" inflate blocksGravatar Denys Vlasenko2019-10-261-10/+20
| | | | | | | | | | function old new delta huft_build 1008 1022 +14 inflate_block 1253 1256 +3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 17/0) Total: 17 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* gunzip: code shrink by using int-, not short-sized struct memberGravatar Denys Vlasenko2019-10-201-1/+2
| | | | | | | | | | | function old new delta inflate_block 1254 1253 -1 inflate_codes 629 621 -8 huft_build 1054 1008 -46 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-55) Total: -55 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* gzip: code shrinkGravatar Denys Vlasenko2019-10-191-29/+26
| | | | | | | | | | | | | | | | | | huft_build() still has way too many params function old new delta lit - 94 +94 dist - 94 +94 huft_build 1058 1054 -4 inflate_block 1281 1254 -27 cpdext 30 - -30 cplext 31 - -31 cpdist 60 - -60 cplens 62 - -62 ------------------------------------------------------------------------------ (add/remove: 2/4 grow/shrink: 0/2 up/down: 188/-214) Total: -26 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* gzip: code shrinkGravatar Denys Vlasenko2019-10-191-27/+26
| | | | | | | | | | | | huft_build() has way too many params function old new delta inflate_block 1293 1281 -12 huft_build 1085 1058 -27 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-39) Total: -39 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* dpkg-deb: work around bogus error message when working with XZ compressed ↵Gravatar Denys Vlasenko2019-10-112-2/+20
| | | | | | | | | | packages function old new delta unpack_xz_stream 2309 2317 +8 bb_full_fd_action 464 472 +8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: reduce the overhead of single parameter bb_error_msg() callsGravatar James Byrne2019-07-0212-39/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* comment fixGravatar Denys Vlasenko2019-05-261-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libarchive: treat one "FIXME: avoid seek", take 2Gravatar Denys Vlasenko2019-05-261-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libarchive: treat one "FIXME: avoid seek"Gravatar Denys Vlasenko2019-05-241-17/+27
| | | | | | | | | | | | function old new delta xmalloc_read_with_initial_buf - 205 +205 setup_transformer_on_fd 154 150 -4 xmalloc_open_zipped_read_close 143 135 -8 xmalloc_read 201 10 -191 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/3 up/down: 205/-203) Total: 2 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bunzip2: the correct condition is "n < groupCount", not "n <= groupCount". ↵Gravatar Denys Vlasenko2019-05-231-1/+1
| | | | | | | | | Closes 11896 function old new delta get_next_block 1677 1681 +4 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* randomconfig fixesGravatar Denys Vlasenko2018-12-271-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: allow hush to run embedded scriptsGravatar Ron Yorston2018-11-271-1/+1
| | | | | | | | | | | | | Embedded scripts require a shell to be present in the BusyBox binary. Allow either ash or hush to be used for this purpose. If both are enabled ash takes precedence. The size of the binary is unchanged in the default configuration: both ash and hush are present but support for embedded scripts isn't compiled into hush. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* tar: skip 'V' headers (GNU volume label), closes 11526Gravatar Denys Vlasenko2018-11-271-1/+2
| | | | | | | function old new delta get_header_tar 1696 1690 -6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* unlzma: fix too-eager corruption checkGravatar Denys Vlasenko2018-11-271-7/+13
| | | | | | | function old new delta unpack_lzma_stream 2686 2674 -12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* tar: fix too eager autodetection, closes 11531Gravatar Denys Vlasenko2018-11-271-2/+1
| | | | | | | | | | | | function old new delta is_suffixed_with - 54 +54 tar_main 1006 1026 +20 open_transformer 92 79 -13 config_file_action 478 458 -20 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/2 up/down: 74/-33) Total: 41 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* remove FAST_FUNC on a static functionGravatar Denys Vlasenko2018-11-021-2/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libarchive: add a function to unpack embedded dataGravatar Ron Yorston2018-11-021-4/+34
| | | | | | | | | | | | | | | | | | | | | Similar code to unpack embedded data is used to decompress usage messages, embedded scripts and the config file (in the non-default bbconfig applet). Moving this code to a common function reduces the size of the default build and hides more of the internals of libarchive. function old new delta unpack_bz2_data - 135 +135 bb_show_usage 137 157 +20 get_script_content 32 47 +15 unpack_scripts 119 - -119 unpack_usage_messages 124 - -124 ------------------------------------------------------------------------------ (add/remove: 1/2 grow/shrink: 2/0 up/down: 170/-243) Total: -73 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: allow shell scripts to be embedded in the binaryGravatar Denys Vlasenko2018-11-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | To assist in the deployment of shell scripts it may be convenient to embed them in the BusyBox binary. 'Embed scripts in the binary' takes any files in the directory 'embed', concatenates them with null separators, compresses them and embeds them in the binary. When scripts are embedded in the binary, scripts can be run as 'busybox SCRIPT [ARGS]' or by usual (sym)link mechanism. embed/nologin is provided as an example. function old new delta packed_scripts - 123 +123 unpack_scripts - 87 +87 ash_main 1103 1171 +68 run_applet_and_exit 78 128 +50 get_script_content - 32 +32 script_names - 10 +10 expmeta 663 659 -4 ------------------------------------------------------------------------------ (add/remove: 4/0 grow/shrink: 2/1 up/down: 370/-4) Total: 366 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* unlzma: close another SEGV possibilityGravatar Denys Vlasenko2018-05-251-1/+5
| | | | | | | function old new delta unpack_lzma_stream 2669 2686 +17 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* tar: fix interaction of delayed symlink and hardlink creationGravatar Harald van Dijk2018-05-223-20/+19
| | | | | | | | | | | | | | | | 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>
* unlzma: do emit the error message on bad input, when we exit with 1Gravatar Denys Vlasenko2018-04-241-0/+6
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* unlzma: fix another SEGV caseGravatar Denys Vlasenko2018-04-191-2/+7
| | | | | | | function old new delta unpack_lzma_stream 1705 1717 +12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ar: stop using static dataGravatar Denys Vlasenko2018-04-151-11/+7
| | | | | | | | | | | function old new delta static.ar_long_names 4 - -4 static.ar_long_name_size 4 - -4 get_header_ar 546 532 -14 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 0/1 up/down: 0/-22) Total: -22 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* dpkg: fix symlink creation, closes 10941Gravatar Denys Vlasenko2018-04-131-1/+3
| | | | | | | function old new delta get_header_ar 434 442 +8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* unlzma: fix segfault on bad archiveGravatar Denys Vlasenko2018-04-081-0/+11
| | | | | | | function old new delta unpack_lzma_stream 2647 2653 +6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bzip2: fix two crashes on corrupted archivesGravatar Denys Vlasenko2018-04-082-23/+56
| | | | | | | | | | | | | | | | As it turns out, longjmp'ing into freed stack is not healthy... function old new delta unpack_usage_messages - 97 +97 unpack_bz2_stream 369 409 +40 get_next_block 1667 1677 +10 get_bits 156 155 -1 start_bunzip 212 183 -29 bb_show_usage 181 120 -61 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/3 up/down: 147/-91) Total: 56 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: new function bb_die_memory_exhaustedGravatar Denys Vlasenko2018-04-011-1/+1
| | | | | | | | | | | | | | | | | | | | function old new delta bb_die_memory_exhausted - 10 +10 xstrdup 28 23 -5 xsetenv 27 22 -5 xrealloc 32 27 -5 xputenv 22 17 -5 xmalloc 30 25 -5 xfdopen_helper 40 35 -5 xasprintf 44 39 -5 wget_main 2387 2382 -5 open_socket 54 49 -5 glob_brace 419 414 -5 bb_get_chunk_from_file 146 141 -5 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/11 up/down: 10/-55) Total: -45 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* tar,unzip: postpone creation of symlinks with "suspicious" targetsGravatar Denys Vlasenko2018-02-202-54/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* bzip2: expose tuning knob for faster/smaller codeGravatar Denys Vlasenko2018-02-074-18/+18
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ar: hopefully fix out-of-bounds read in get_header_ar()Gravatar Denys Vlasenko2018-02-061-2/+2
| | | | | | https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=882175 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bzip2: work around bad compiler optimizationGravatar Denys Vlasenko2018-02-051-32/+43
| | | | | | | | | | | | | | | | | | | | | | | | gc-6.1.1 x86_64: function old new delta generateMTFValues 380 367 -13 gcc-4.3.1 386: function old new delta inner_loop - 41 +41 generateMTFValues 357 294 -63 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 41/-63) Total: -22 bytes gcc-6.3.0 386: function old new delta inner_loop - 36 +36 generateMTFValues 363 250 -113 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 36/-113) Total: -77 bytes The last case, gcc-6.3.0, runs almost 3 times faster after this change. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* gunzip: fix from gzip-1.3.12 for gzip file with all zero length codesGravatar Denys Vlasenko2018-02-041-4/+11
| | | | | | | | | | | | | | | | | | Corresponding changelog from gzip-1.3.12 reads: """ 2006-12-20 Paul Eggert <eggert@cs.ucla.edu> * inflate.c (huft_build): Fix regression that caused gzip to refuse to uncompress null input (all zero length codes). Problem reported by Yiorgos Adamopoulos. This regression was caused by the security patch installed 2006-11-20, which in turn came from Debian, which in turn apparently came from Thomas Biege of SuSe. """ function old new delta huft_build 1176 1216 +40 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bzip2: move runningOrder[] back to stack - 256 bytes is not muchGravatar Denys Vlasenko2018-02-032-6/+8
| | | | | | | function old new delta mainSort 1119 1108 -11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bzip2: move ->origPtr out of struct EState, make a few members smallerGravatar Denys Vlasenko2018-02-033-27/+27
| | | | | | | | | | | | | function old new delta BZ2_compressBlock 223 228 +5 BZ2_blockSort 85 88 +3 generateMTFValues 356 357 +1 handle_compress 355 349 -6 compressStream 538 531 -7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/2 up/down: 9/-13) Total: -4 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bzip2: pass sorting params through EState* pointerGravatar Denys Vlasenko2018-02-033-67/+65
| | | | | | | | | | | | | | | function old new delta mainGtU 499 515 +16 sendMTFValues 2085 2094 +9 mainSort 1116 1119 +3 generateMTFValues 357 356 -1 fallbackSort 1719 1705 -14 mainQSort3 1163 1141 -22 BZ2_blockSort 118 85 -33 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/4 up/down: 28/-70) Total: -42 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* gzip2: small simplification in mainSimpleSort()Gravatar Denys Vlasenko2018-02-031-14/+15
| | | | | | | function old new delta mainQSort3 1165 1163 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bzip2: a few more locals converted to generic typesGravatar Denys Vlasenko2018-02-031-7/+7
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bzip2: eliminate one parameter to mainQSort3()Gravatar Denys Vlasenko2018-02-031-5/+9
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bzip2: small simplification in mainSort()Gravatar Denys Vlasenko2018-02-031-5/+5
| | | | | | | function old new delta mainSort 1127 1118 -9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bzip2: convert some locals to unsigned'sGravatar Denys Vlasenko2018-02-031-5/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bzip2: runningOrder[] values are always 0..255, make it uint8Gravatar Denys Vlasenko2018-02-032-6/+5
| | | | | | | function old new delta mainSort 1171 1124 -47 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>