Commit Graph

135 Commits

Author SHA1 Message Date
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
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
bb373dbc32 tar: accomodate non-terminated tar.chksum fields as seen from github.com
function                                             old     new   delta
get_header_tar                                      1783    1696     -87

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-01-27 19:04:08 +01:00
Denys Vlasenko
9ac42c5005 unlzma: fix SEGV, closes 10436
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-10-27 15:37:03 +02:00
Denys Vlasenko
0402cb32df bunzip2: fix runCnt overflow from bug 10431
This particular corrupted file can be dealth with by using "unsigned".
If there will be cases where it genuinely overflows, there is a disabled
code to deal with that too.

function                                             old     new   delta
get_next_block                                      1678    1667     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-10-22 18:23:23 +02:00
Denys Vlasenko
2ab9403119 whitespace and comment format fixes, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-10-05 15:33:28 +02:00
Denys Vlasenko
ebe6d9d875 whitespace and comment format fixes, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-10-05 14:40:24 +02:00
Ron Yorston
e837a0dbbe libarchive: fix build failure on NOMMU systems
In the old code fd was an argument, now we need to get the file descriptor
from the xstate structure.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-22 15:41:33 +02:00
Denys Vlasenko
bc9bbeb2b8 libarchive: do not extract unsafe symlinks unless $EXTRACT_UNSAFE_SYMLINKS=1
function                                             old     new   delta
unsafe_symlink_target                                  -     147    +147
unzip_main                                          2711    2732     +21
copy_file                                           1657    1678     +21
tar_main                                             999     971     -28
data_extract_all                                    1038     984     -54
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/2 up/down: 189/-82)           Total: 107 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-10 11:52:42 +02:00
Denys Vlasenko
0cf64c8b5d rpm2cpio: handle LZMA compressed rpms. closes 10166
function                                             old     new   delta
rpm2cpio_main                                         78     120     +42
setup_lzma_on_fd                                       -      29     +29
fork_transformer_and_free                              -      28     +28
...
setup_unzip_on_fd                                     56      32     -24
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 3/5 up/down: 104/-67)            Total: 37 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-10 10:36:37 +02:00
Denys Vlasenko
76b65624b9 unxz: get_le32 macro is obviously wrong
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-07 20:56:54 +02:00
Denys Vlasenko
b920a38dc0 tar: postpone creation of symlinks with "suspicious" targets. Closes 8411
function                                             old     new   delta
data_extract_all                                     968    1038     +70
tar_main                                             952     986     +34
scan_tree                                            258     262      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 108/0)             Total: 108 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-24 17:20:13 +02:00
Denys Vlasenko
2c1258c620 Move get_unaligned_le32() macros to platform.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-15 20:22:25 +02:00
Denys Vlasenko
10ad622dc2 Spelling fixes in comments, documentation, tests and examples
By klemens <ka7@github.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-17 16:13:32 +02:00
Kang-Che Sung
74c2215086 Fix FEATURE_{GZIP,BZIP2}_DECOMPRESS link error
... when gzip is selected but not gunzip nor zcat, or when bzip2 is
selected but not bunzip2 nor bzcat.

This regression is introduced in b130f9f758
("Allow 'gzip -d' and 'bzip2 -d' without gunzip or bunzip2")

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-02-17 20:15:27 +01:00
Rostislav Skudnov
8762512fdb Replace int -> uint to avoid signed integer overflow
An example of such an error (should be compiled with DEBUG_SANITIZE):

runtime error: left shift of 1 by 31 places cannot be represented in
type 'int'

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-02-04 23:10:22 +01:00
Denys Vlasenko
06f20bf675 link: new applet
coreutils grew itself a tiny simplistic alternative to ln:

	Usage: link FILE LINK

	Create hard LINK to FILE

function                                             old     new   delta
link_main                                              -      75     +75
packed_usage                                       31114   31131     +17
applet_names                                        2564    2569      +5
applet_main                                         1480    1484      +4
applet_install_loc                                   185     186      +1
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/0 up/down: 102/0)             Total: 102 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-26 00:27:53 +01:00
Denys Vlasenko
590402bb55 unlzma: expand comments, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-09 14:28:25 +01:00
Denys Vlasenko
3989e5adf4 unlzma: fix erroneous "while" instead of "if". Closes 4682
These parts of the code essentially check whether
stepping back by rep0 goes negative or not.

LZMA SDK from lzma1604.7z has the following in the corresponding places:

... = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)]

Clearly, not loop here.

Technically, "while" here works: if condition is false (because pos
underflowed), it iterates once, adds header.dict_size (a.k.a. dicBufSize),
this makes pos positive but smaller than header.dict_size, and loop exits.

Now we'll just check for negative result of subtraction, which is less code:

function                                             old     new   delta
unpack_lzma_stream                                  2659    2641     -18

(I hope 2 Gbyte+ dictionaries won't be in use soon).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-09 14:02:55 +01:00
Denys Vlasenko
6b4f4b5284 unzip: optional support for xz
function                                             old     new   delta
unzip_main                                          2476    2491     +15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-09 11:12:01 +01:00
Denys Vlasenko
2a0867a5ed unzip: optional support for bzip2 and lzma
function                                             old     new   delta
unzip_main                                          2376    2476    +100
bbunpack                                             750     745      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-09 10:58:37 +01:00
Denys Vlasenko
548620c18b randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-08 12:24:48 +01:00
Denys Vlasenko
9655f95d0f tar: handle pax-encoded utf8 filenames and link names. Closes 9406
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-11 17:56:45 +01:00
Denys Vlasenko
85100a7067 cpio: fix restoration of file ownership, closes 9306
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-12 20:56:46 +02:00
Denys Vlasenko
10c0e91786 libarchive: fix xmalloc_open_zipped_read_close()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-06-21 02:04:16 +02:00
Denys Vlasenko
e24e88697a typo fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-06-20 16:28:53 +02:00
Denys Vlasenko
df3ec0e2f7 libarchive: fix open_zipped()
Last commit broke it (on both MMU and NOMMU)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-06-20 11:42:00 +02:00
Denys Vlasenko
984b0a613a libarchive: fix xmalloc_open_zipped_read_close() on NOMMU
The somewhat new "unpack in memory" code was broken
for xmalloc_open_zipped_read_close() on NOMMU: we seek back
over signature, but then expect it to be already consumed.
Stop seeking back in this case.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-06-20 11:06:42 +02:00
Denys Vlasenko
015db5800c randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-06-19 18:15:33 +02:00
Denys Vlasenko
3e134ebf6a *: slap on a few ALIGN1/2s where appropriate
The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map"

   text	   data	    bss	    dec	    hex	filename
 829901	   4086	   1904	 835891	  cc133	busybox_before
 829665	   4086	   1904	 835655	  cc047	busybox

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-22 18:09:21 +02:00