Commit Graph

1451 Commits

Author SHA1 Message Date
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