Commit Graph

1483 Commits

Author SHA1 Message Date
Denys Vlasenko
7c443d110d randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-24 00:27:37 +02:00
Lauri Kasanen
b9943741c2 unzip: -d should create the dir
The official Info-Zip unzip creates the dir if it doesn't exist.

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-04-29 14:37:21 +02:00
Denys Vlasenko
2f57b5139e unxz: show -t in --help
function                                             old     new   delta
packed_usage                                       33236   33247     +11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-11-08 16:37:28 +01:00
Denys Vlasenko
caf5ee0dd9 gunzip: fix incorrect decoding of "fixed" inflate blocks
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>
2019-10-26 20:04:34 +02:00
Denys Vlasenko
e1a7c97ac6 tar: fix fallout of: change -a from meaning "lzma" to mean "autodetect by extension"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-25 10:30:53 +02:00
Denys Vlasenko
fb1103595f gunzip: code shrink by using int-, not short-sized struct member
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>
2019-10-20 19:07:06 +02:00
Denys Vlasenko
6572ef6e1e gzip: code shrink
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>
2019-10-19 18:53:19 +02:00
Denys Vlasenko
c763392458 gzip: code shrink
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>
2019-10-19 18:33:49 +02:00
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