Commit Graph

1525 Commits

Author SHA1 Message Date
Denys Vlasenko
42f454b13b dpkg-deb: work around bogus error message when working with XZ compressed 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>
2019-10-11 14:11:44 +02:00
Denys Vlasenko
d327c6b190 gzip: code shrink
Converted a few 16-bit variables and small arrays to 32-bit.

Stopped pulling desc->FOO members into temporary local variables
in gen_bitlen(): on register-starved arches, this is a loss,
temporaries go into stack slots.

Sprinkled a few "const" on pointer arguments.

function                                             old     new   delta
pack_gzip                                            742     745      +3
gen_codes                                            101      97      -4
build_tree                                           886     833     -53
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 3/-57)             Total: -54 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-09-06 17:59:45 +02:00
Denys Vlasenko
750137ef7c gzip: code shrink
function                                             old     new   delta
gzip_main                                            267     264      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-09-05 13:26:58 +02:00
Daniel Edgecumbe
c660cc1b77 gzip: set default compression level to 6 when CONFIG_FEATURE_GZIP_LEVELS=n
With this change, GNU gzip -n and BusyBox gzip now produce identical output
assuming that CONFIG_GZIP_FAST=2.

>> Excuse me, but I wonder one thing: Why should we follow
>> strictly with gzip on the no-options default behavior?

> First, the default 6 compression level is a de-facto standard. BSD gzip
> and Apple gzip (on macOS) use this default as well. So there is a
> reasonable expectation that different gzip implementations act the same.
> For instance, if the default for busybox gzip becomes 9, then someone
> writing a script using busybox gzip could reasonably expect that the
> compression level will still be 9 when the same script is run on another
> system. That would be wrong. Implementations should not deviate from
> de-facto standards without a strong reason.
>
> Second, the inherent reason for this default has not gone away. While
> processor speeds have exploded since the default was set, so has the
> typical size of compressed files. Multiple gigabytes are nothing unusual
> these days. And gzip is often used for compression on the fly, precisely
> because it offers a good compromise between speed and compression ratio.
> So I believe 6 continues to be a reasonable default.

function                                             old     new   delta
deflate                                              939     927     -12

Signed-off-by: Daniel Edgecumbe <git@esotericnonsense.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-09-05 13:26:58 +02:00
Daniel Edgecumbe
ca5d86d52c gzip: set compression flags correctly as per standard
With this change and CONFIG_GZIP_FAST=2, CONFIG_FEATURE_GZIP_LEVELS=y,

GNU gzip and BusyBox gzip now produce identical output at each compression
level (excluding 1..3, as BusyBox does not implement these levels).

Signed-off-by: Daniel Edgecumbe <git@esotericnonsense.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-09-05 13:26:58 +02:00
Daniel Edgecumbe
de82f0b764 gzip: default level with ENABLE_FEATURE_GZIP_LEVELS should be 6
Fixes an off-by-one that actually resulted in level 7 being used

Signed-off-by: Daniel Edgecumbe <git@esotericnonsense.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-09-05 13:26:58 +02:00
Denys Vlasenko
16474cf246 tar: change -a from meaning "lzma" to mean "autodetect by extension"
function                                             old     new   delta
tar_main                                            1026    1100     +74
packed_usage                                       33311   33329     +18
tar_longopts                                         309     325     +16
vfork_compressor                                     246     210     -36
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 108/-36)            Total: 72 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-08-02 15:19:56 +02:00
Denys Vlasenko
e6a87e7483 tar: code shrink
function                                             old     new   delta
writeLongname                                        226     228      +2
static.prefilled                                      48       -     -48
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 2/-48)             Total: -46 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-08-01 15:07:21 +02:00
James Byrne
6937487be7 libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d437 ("'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>
2019-07-02 11:35:03 +02:00
Denys Vlasenko
eda83c9e69 comment fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-26 13:46:49 +02:00
Denys Vlasenko
cc71f79c1e libarchive: treat one "FIXME: avoid seek", take 2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-26 13:43:06 +02:00
Denys Vlasenko
dff2bd733f libarchive: treat one "FIXME: avoid seek"
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>
2019-05-24 17:03:28 +02:00
Denys Vlasenko
58d998d2f9 bunzip2: the correct condition is "n < groupCount", not "n <= groupCount". Closes 11896
function                                             old     new   delta
get_next_block                                      1677    1681      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-23 14:54:13 +02:00
Denys Vlasenko
f9b4cc114c config: dpkg_deb should be dpkg-deb
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-28 18:24:45 +01:00
Denys Vlasenko
b86b39bfda config: more tweaks
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-28 17:52:43 +01:00
Denys Vlasenko
b097a84d62 config: update size information
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-28 03:20:17 +01:00
Denys Vlasenko
3d27d435db randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-27 18:03:20 +01:00
Ron Yorston
71df2d3589 hush: allow hush to run embedded scripts
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>
2018-11-27 16:13:07 +01:00
Denys Vlasenko
403d2574be tar: skip 'V' headers (GNU volume label), closes 11526
function                                             old     new   delta
get_header_tar                                      1696    1690      -6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-27 12:09:01 +01:00
Denys Vlasenko
e80d04b574 unlzma: fix too-eager corruption check
function                                             old     new   delta
unpack_lzma_stream                                  2686    2674     -12

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-27 11:52:14 +01:00
Denys Vlasenko
f4fc303e36 tar: fix too eager autodetection, closes 11531
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>
2018-11-27 11:26:48 +01:00
Denys Vlasenko
97c2a6d082 remove FAST_FUNC on a static function
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-02 14:20:54 +01:00
Ron Yorston
c339c7f7b3 libarchive: add a function to unpack embedded data
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>
2018-11-02 14:14:51 +01:00
Denys Vlasenko
4f2ef4a836 ash: allow shell scripts to be embedded in the binary
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>
2018-11-01 10:15:13 +01:00
Denys Vlasenko
349d72c19c unzip: use printable_string() for printing filenames
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-09-30 16:56:56 +02:00
Denys Vlasenko
2005d3ff36 tar: fix a thinko in prev commit - we need to copy to _unused_ fd
function                                             old     new   delta
vfork_compressor                                     257     246     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-08-04 21:06:02 +02:00
Denys Vlasenko
037759bb4f tar: handle the case when opened created tarball happens to have fd#0
Reproducer:
    exec 0>&-
    exec 1>&-
    tar czf z.tar.gz FILE

function                                             old     new   delta
vfork_compressor                                     229     257     +28

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-08-04 18:15:19 +02:00
Denys Vlasenko
45d68c3749 tar: make source code a bit more terse, no logic changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-08-04 17:48:59 +02:00
Denys Vlasenko
81de30de05 gzip: unbreak FEATURE_GZIP_LEVELS, closes 11171
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-24 21:12:58 +02:00
Denys Vlasenko
9be4d4fe44 cpio: if longopts are enabled, accept --null (synonym for -0)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-06 20:50:30 +02:00
Denys Vlasenko
4d0e2d5b6d tweak help texts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-06 20:49:08 +02:00
Kartik Agaram
43b17b1cd0 restore documentation on the build config language
Kconfig-language.txt was deleted in commit 4fa499a17b back in 2006.
Move to docs/ as suggested by Xabier Oneca:
  http://lists.busybox.net/pipermail/busybox/2014-May/080914.html
Also update references to it everywhere.

Signed-off-by: Kartik Agaram <akkartik@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-06 15:16:48 +02:00
Denys Vlasenko
a36986bb80 unlzma: close another SEGV possibility
function                                             old     new   delta
unpack_lzma_stream                                  2669    2686     +17

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-05-25 17:03:46 +02:00
Harald van Dijk
8c24af9dcf tar: fix interaction of delayed symlink and hardlink creation
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-05-22 17:34:31 +02:00
Denys Vlasenko
77bf05dfe3 unlzma: do emit the error message on bad input, when we exit with 1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-24 13:49:12 +02:00
Denys Vlasenko
e09c426456 unlzma: fix another SEGV case
function                                             old     new   delta
unpack_lzma_stream                                  1705    1717     +12

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-19 19:30:51 +02:00
Denys Vlasenko
b74e490629 ar: stop using static data
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>
2018-04-15 14:18:16 +02:00
Denys Vlasenko
dd56921e2d dpkg: fix symlink creation, closes 10941
function                                             old     new   delta
get_header_ar                                        434     442      +8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-13 13:27:52 +02:00
Denys Vlasenko
a1870f4807 unlzma: fix segfault on bad archive
function                                             old     new   delta
unpack_lzma_stream                                  2647    2653      +6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-08 20:45:16 +02:00
Denys Vlasenko
38ccd6af8a bzip2: fix two crashes on corrupted archives
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>
2018-04-08 20:05:04 +02:00
Denys Vlasenko
87a08e476b lzop: remove method checks which are always true/false
function                                             old     new   delta
do_lzo_compress                                      232     224      -8
lzo_compress                                         531     488     -43
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-51)             Total: -51 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-08 16:44:45 +02:00
Denys Vlasenko
3d4f688a19 lzop: buffer several 32-bit writes when we start a new compressed block
function                                             old     new   delta
lzo_compress                                         483     531     +48

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-08 16:31:02 +02:00
Denys Vlasenko
24ef5c6375 lzop: reuse strings
function                                             old     new   delta
lzo_compress                                         470     483     +13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 13/0)               Total: 13 bytes
   text    data     bss     dec     hex filename
 940011     477    7284  947772   e763c busybox_old
 939976     477    7284  947737   e7619 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-08 14:00:03 +02:00
Denys Vlasenko
15684bf545 lzop: checksum reads do not need to be checksummed
function                                             old     new   delta
do_lzo_decompress                                    404     427     +23
f_read32                                              22       -     -22

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-08 13:45:04 +02:00
Denys Vlasenko
3a7d16d488 lzop: don't support ancient versions < 0.94 (15 Oct 1997)
0.94 came only 2 months after initial 0.90:

    0.90 (10 Aug 1997): First public release of lzop
    ...
    0.94 (15 Oct 1997): Header format change

function                                             old     new   delta
do_lzo_decompress                                    411     404      -7
f_read8                                               24       -     -24
f_read16                                              31       -     -31
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/1 up/down: 0/-62)             Total: -62 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-08 13:35:28 +02:00
Denys Vlasenko
434f95960a lzop: code shrink by using header_t matching on-disk layout
function                                             old     new   delta
add_bytes_to_chksum                                   37      47     +10
lzo_decompress                                       524     532      +8
init_chksum                                           14      21      +7
chksum_getresult                                      13      17      +4
f_read                                                33      28      -5
f_write8                                              20       -     -20
f_write32                                             22       -     -22
f_write16                                             25       -     -25
f_write                                               36       -     -36
do_lzo_compress                                      328     232     -96
do_lzo_decompress                                    526     411    -115
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 4/3 up/down: 29/-319)          Total: -290 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-08 13:33:43 +02:00
Denys Vlasenko
7924b69f99 tar: trim help text
Usage: tar c|x|t [-ZzJjahmvokO] [-f TARFILE] [-C DIR] [-T FILE] [-X FILE] [--exclude PATTERN]... [FILE]...

Create, extract, or list files from a tar file

Operation:  <============== DELETED
    c	Create
    x	Extract
    t	List
    -f FILE	Name of TARFILE ('-' for stdin/out)
    -C DIR	Change to DIR before operation
    -v	Verbose
    -O	Extract to stdout
    -m	Don't restore mtime
    -o	Don't restore user:group
    -k	Don't replace existing files
    -Z	(De)compress using compress
    -z	(De)compress using gzip
    -J	(De)compress using xz
    -j	(De)compress using bzip2
    -a	(De)compress using lzma
    -h	Follow symlinks
    -T FILE	File with names to include
    -X FILE	File with glob patterns to exclude
    --exclude PATTERN	Glob pattern to exclude

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07 21:04:39 +02:00
Denys Vlasenko
899ae5337a libbb: new function bb_die_memory_exhausted
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>
2018-04-01 19:59:37 +02:00
Natanael Copa
d9503224c8 cpio: extract "unsafe" symlinks the same way tar/unzip does
function                                             old     new   delta
cpio_main                                            588     596      +8

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-30 20:18:12 +02:00
Denys Vlasenko
3c08437db7 tar: add -o and -k to short --help too
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-16 04:02:23 +01:00
Denys Vlasenko
1ee222e1bf tar: add -k and -o to --help
-o	Don't restore user:group
    -k	Don't replace existing files

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-16 03:55:14 +01:00
Denys Vlasenko
a84db18fc7 tar,unzip: postpone creation of symlinks with "suspicious" targets
This mostly reverts commit bc9bbeb2b8
"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-20 16:06:53 +01:00
Denys Vlasenko
4cae044b43 bzip2: expose tuning knob for faster/smaller code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-07 01:33:25 +01:00
Denys Vlasenko
5cdd120f0c unzip: do not set directory mode to 0777
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=882177

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-06 17:59:32 +01:00
Denys Vlasenko
0a90960f44 ar: hopefully fix out-of-bounds read in get_header_ar()
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=882175

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-06 17:39:45 +01:00
Denys Vlasenko
c2a51b0cf1 bzip2: work around bad compiler optimization
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>
2018-02-05 00:34:08 +01:00
Denys Vlasenko
2598915d43 gunzip: fix from gzip-1.3.12 for gzip file with all zero length codes
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>
2018-02-04 00:15:29 +01:00
Denys Vlasenko
0e60a36c92 bzip2: move runningOrder[] back to stack - 256 bytes is not much
function                                             old     new   delta
mainSort                                            1119    1108     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 22:52:55 +01:00
Denys Vlasenko
86be6d5ba9 bzip2: move ->origPtr out of struct EState, make a few members smaller
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>
2018-02-03 20:51:12 +01:00
Denys Vlasenko
c9ae8d770b bzip2: pass sorting params through EState* pointer
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>
2018-02-03 20:19:51 +01:00
Denys Vlasenko
10f516500e gzip2: small simplification in mainSimpleSort()
function                                             old     new   delta
mainQSort3                                          1165    1163      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 19:11:00 +01:00
Denys Vlasenko
0599a137ba bzip2: a few more locals converted to generic types
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 18:47:34 +01:00
Denys Vlasenko
8e31412231 bzip2: eliminate one parameter to mainQSort3()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 18:28:10 +01:00
Denys Vlasenko
9431bdd189 bzip2: small simplification in mainSort()
function                                             old     new   delta
mainSort                                            1127    1118      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 18:11:08 +01:00
Denys Vlasenko
fe1bab4d35 bzip2: convert some locals to unsigned's
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 18:03:33 +01:00
Denys Vlasenko
c364d32ccc bzip2: runningOrder[] values are always 0..255, make it uint8
function                                             old     new   delta
mainSort                                            1171    1124     -47

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 17:44:00 +01:00
Denys Vlasenko
df23f55e39 bzip2: remove redundant clearing of an alredy unset bit
function                                             old     new   delta
mainSort                                            1178    1171      -7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 17:38:23 +01:00
Denys Vlasenko
524fa29a93 bzip2: eliminate write-only local numQSorted
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 17:30:16 +01:00
Denys Vlasenko
2109fce410 bzip2: make locals in mainSort() saner, convert one of them from uint16 to unsigned
function                                             old     new   delta
mainSort                                            1192    1178     -14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 17:22:06 +01:00
Denys Vlasenko
aaa3818a75 bzip2: remove redundant loop termination check in mainSort()
function                                             old     new   delta
mainSort                                            1202    1192     -10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 16:43:33 +01:00
Denys Vlasenko
e59e5ff96e bzip2: reduce indentation, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 15:59:46 +01:00
Denys Vlasenko
9e5662ea74 bzip2: reuse zPend processing code
function                                             old     new   delta
generateMTFValues                                    378     357     -21

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 15:53:17 +01:00
Denys Vlasenko
2cfe10a558 bzip2: shrink makeMaps_e()
function                                             old     new   delta
generateMTFValues                                    378     368     -10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 15:31:54 +01:00
Denys Vlasenko
1cbcb02316 bzip2: optimize zPend variable code
function                                             old     new   delta
generateMTFValues                                    433     378     -55

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 15:26:00 +01:00
Denys Vlasenko
fc228b48c9 bzip2: have two separate "store bit 0" and "store bit 1" functions
function                                             old     new   delta
sendMTFValues                                       2051    2085     +34
bsW1_0                                                 -      33     +33
BZ2_compressBlock                                    225     223      -2
bsW1                                                  52       -     -52
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/1 up/down: 67/-54)             Total: 13 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 14:56:43 +01:00
Denys Vlasenko
feafb3423e bzip2: ~1% speedup by special-casing "store 1 bit" function
function                                             old     new   delta
bsW1                                                   -      52     +52
BZ2_compressBlock                                    230     225      -5
BZ2_blockSort                                        125     118      -7
sendMTFValues                                       2070    2051     -19
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 52/-31)             Total: 21 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 04:43:46 +01:00
Denys Vlasenko
982c44d030 bzip2: rewrite bit of code which depends on integer overflow
function                                             old     new   delta
sendMTFValues                                       2093    2070     -23

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 03:34:40 +01:00
Denys Vlasenko
83dd4ff696 bzip2: delete write-only fave[] array
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 03:17:48 +01:00
Denys Vlasenko
3a2c97bd12 bgip2: fewer specifically-sized [u]int32_t's locals in sendMTFValues
Generic ints/unsigneds are usually fine. Yes, really.

function                                             old     new   delta
sendMTFValues                                       2100    2093      -7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 03:14:07 +01:00
Denys Vlasenko
359230da8e bzip2: code shrink
function                                             old     new   delta
sendMTFValues                                       2111    2100     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 02:03:42 +01:00
Denys Vlasenko
e594fb2171 bzip2: code shrink
function                                             old     new   delta
BZ2_compressBlock                                    225     230      +5
handle_compress                                      356     355      -1
bsW16                                                 59      56      -3
bsW                                                   64      61      -3
bsFinishWrite                                         37      32      -5
prepare_new_block                                     48      34     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/5 up/down: 5/-26)             Total: -21 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-03 01:30:12 +01:00
Denys Vlasenko
125c3ff4b1 bzip2: code shrink
function                                             old     new   delta
bsW16                                                  -      59     +59
sendMTFValues                                       2116    2111      -5
bsPutU16                                              36       -     -36
bsPutU32                                              76      31     -45
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/2 up/down: 59/-86)            Total: -27 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-02 20:59:28 +01:00
Denys Vlasenko
ddacb03e87 libbb: commonalize a bit of little-endian CRC32 table generation code
function                                             old     new   delta
global_crc32_new_table_le                              -      11     +11
crc32_new_table_le                                     -       9      +9
inflate_unzip_internal                               560     556      -4
flash_eraseall_main                                  823     819      -4
unpack_xz_stream                                    2403    2394      -9
lzop_main                                            121     112      -9
gzip_main                                            187     178      -9
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/5 up/down: 20/-35)            Total: -15 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-01 10:56:19 +01:00
Denys Vlasenko
d6f0f03b68 libarchive: move bbunpack constants to bb_archive.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-01 09:13:14 +01:00
Denys Vlasenko
99ac1759dd lzop: code shrink
function                                             old     new   delta
lzo_decompress                                       526     524      -2
lzo_compress                                         473     470      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-01 01:41:31 +01:00
Denys Vlasenko
97058d0585 unlzop: fix --help: it has -U instead of -k
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-01 01:03:50 +01:00
Denys Vlasenko
1b8ac93a20 bzip2: code shrink, stop using global data variable
function                                             old     new   delta
compressStream                                       523     538     +15
level                                                  1       -      -1
bzip2_main                                           110      73     -37
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 15/-38)            Total: -23 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-01 01:00:58 +01:00
Denys Vlasenko
54a174eb01 gzip: "compressed_len" is unused, stop wasting code and time calculating it
function                                             old     new   delta
flush_block                                          595     523     -72

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-01-31 23:26:11 +01:00
Denys Vlasenko
a142926029 gzip: remove unnecessary forward declarations, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-01-31 18:16:34 +01:00
Denys Vlasenko
919bc9d43c gzip: flush output buffer after stored blocks only if necessary
function                                             old     new   delta
flush_block                                          671     680      +9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-01-31 17:37:32 +01:00
Denys Vlasenko
f21ebeece5 gzip: flush output buffer after stored blocks, they are not 32-bit aligned
function                                             old     new   delta
flush_block                                          665     671      +6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-01-31 17:19:59 +01:00
Denys Vlasenko
ba63d70e2d gzip: make debugging of bits_sent less ugly, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-01-31 17:00:41 +01:00
Denys Vlasenko
26eea71c87 gzip: code shrink
function                                             old     new   delta
flush_block                                          668     665      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-01-31 16:36:17 +01:00
Denys Vlasenko
05251986c7 gzip: code shrink
Use one memset to clear part of G1, and all of G2.

function                                             old     new   delta
pack_gzip                                            838     828     -10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-01-31 16:11:56 +01:00
Denys Vlasenko
8fd35a1fa6 gzip: code shrink
function                                             old     new   delta
pack_gzip                                            861     838     -23

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-01-31 15:42:45 +01:00
Denys Vlasenko
468731a86b gzip: code shrink and speedup
function                                             old     new   delta
pack_gzip                                            908     861     -47

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-01-31 15:32:32 +01:00
Denys Vlasenko
631c16855a gzip: optionally faster put_32bit()
function                                             old     new   delta
put_32bit                                             22      55     +33

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-01-31 00:42:29 +01:00
Denys Vlasenko
b7dfbbcdaa gzip: speed up send_bits()
Replace one RMW op with store. This speeds up gzip of a png file by ~2%.

function                                             old     new   delta
send_bits                                             62      66      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-01-31 00:01:06 +01:00
Denys Vlasenko
d7500f856d gzip: use "unsigned" type for bit fields and bit counts
This does not change any logic, those values should always be positive.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-01-30 23:53:38 +01:00
Denys Vlasenko
6ba6a6f28e gzip: use wider (32-bit, not 16) bi_buf
function                                             old     new   delta
bi_windup                                             76      74      -2
send_bits                                             70      62      -8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-01-30 23:47:45 +01:00