aboutsummaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-03-23 11:13:23 +0000
committerRon Yorston <rmy@pobox.com>2012-03-23 11:13:23 +0000
commit40514a0309939f2446f0d4ed9600cad5de396e7f (patch)
tree0f5f4a57d4bb7893418b5bb11d482858eb17ba8b /archival
parent9db164d6e39050d09f38288c6045cd2a2cbf6d63 (diff)
parentc0cae52662ccced9df19f19ec94238d1b1e3bd71 (diff)
downloadbusybox-w32-40514a0309939f2446f0d4ed9600cad5de396e7f.tar.gz
busybox-w32-40514a0309939f2446f0d4ed9600cad5de396e7f.tar.bz2
busybox-w32-40514a0309939f2446f0d4ed9600cad5de396e7f.zip
Merge commit 'c0cae52662ccced9df19f19ec94238d1b1e3bd71' into merge
Conflicts: Makefile.flags scripts/basic/fixdep.c
Diffstat (limited to 'archival')
-rw-r--r--archival/Config.src19
-rw-r--r--archival/ar.c2
-rw-r--r--archival/bbunzip.c9
-rw-r--r--archival/bzip2.c6
-rw-r--r--archival/cpio.c2
-rw-r--r--archival/dpkg.c2
-rw-r--r--archival/dpkg_deb.c2
-rw-r--r--archival/gzip.c12
-rw-r--r--archival/libarchive/bz/blocksort.c8
-rw-r--r--archival/libarchive/bz/bzlib_private.h2
-rw-r--r--archival/libarchive/bz/compress.c8
-rw-r--r--archival/libarchive/bz/huffman.c2
-rw-r--r--archival/libarchive/data_align.c2
-rw-r--r--archival/libarchive/data_extract_all.c2
-rw-r--r--archival/libarchive/data_extract_to_command.c2
-rw-r--r--archival/libarchive/data_extract_to_stdout.c2
-rw-r--r--archival/libarchive/data_skip.c2
-rw-r--r--archival/libarchive/decompress_bunzip2.c11
-rw-r--r--archival/libarchive/decompress_uncompress.c15
-rw-r--r--archival/libarchive/decompress_unlzma.c2
-rw-r--r--archival/libarchive/decompress_unxz.c2
-rw-r--r--archival/libarchive/decompress_unzip.c2
-rw-r--r--archival/libarchive/filter_accept_all.c2
-rw-r--r--archival/libarchive/filter_accept_list.c2
-rw-r--r--archival/libarchive/filter_accept_list_reassign.c2
-rw-r--r--archival/libarchive/filter_accept_reject_list.c2
-rw-r--r--archival/libarchive/find_list_entry.c2
-rw-r--r--archival/libarchive/get_header_ar.c2
-rw-r--r--archival/libarchive/get_header_cpio.c2
-rw-r--r--archival/libarchive/get_header_tar.c10
-rw-r--r--archival/libarchive/get_header_tar_bz2.c2
-rw-r--r--archival/libarchive/get_header_tar_gz.c2
-rw-r--r--archival/libarchive/get_header_tar_lzma.c2
-rw-r--r--archival/libarchive/header_list.c2
-rw-r--r--archival/libarchive/header_skip.c2
-rw-r--r--archival/libarchive/header_verbose_list.c2
-rw-r--r--archival/libarchive/init_handle.c2
-rw-r--r--archival/libarchive/open_transformer.c2
-rw-r--r--archival/libarchive/seek_by_jump.c2
-rw-r--r--archival/libarchive/seek_by_read.c2
-rw-r--r--archival/libarchive/unpack_ar_archive.c2
-rw-r--r--archival/lzop.c2
-rw-r--r--archival/rpm.c2
-rw-r--r--archival/rpm2cpio.c2
-rw-r--r--archival/tar.c2
-rw-r--r--archival/unzip.c7
46 files changed, 105 insertions, 72 deletions
diff --git a/archival/Config.src b/archival/Config.src
index 7e493f56f..f1d6d3511 100644
--- a/archival/Config.src
+++ b/archival/Config.src
@@ -187,6 +187,18 @@ config FEATURE_GZIP_LONG_OPTIONS
187 help 187 help
188 Enable use of long options, increases size by about 106 Bytes 188 Enable use of long options, increases size by about 106 Bytes
189 189
190config GZIP_FAST
191 int "Trade memory for gzip speed (0:small,slow - 2:fast,big)"
192 default 0
193 range 0 2
194 depends on GZIP
195 help
196 Enable big memory options for gzip.
197 0: small buffers, small hash-tables
198 1: larger buffers, larger hash-tables
199 2: larger buffers, largest hash-tables
200 Larger models may give slightly better compression
201
190config LZOP 202config LZOP
191 bool "lzop" 203 bool "lzop"
192 default y 204 default y
@@ -331,15 +343,12 @@ config UNLZMA
331 is generally considerably better than that achieved by the bzip2 343 is generally considerably better than that achieved by the bzip2
332 compressors. 344 compressors.
333 345
334 The BusyBox unlzma applet is limited to de-compression only. 346 The BusyBox unlzma applet is limited to decompression only.
335 On an x86 system, this applet adds about 4K. 347 On an x86 system, this applet adds about 4K.
336 348
337 Unless you have a specific application which requires unlzma, you
338 should probably say N here.
339
340config FEATURE_LZMA_FAST 349config FEATURE_LZMA_FAST
341 bool "Optimize unlzma for speed" 350 bool "Optimize unlzma for speed"
342 default y 351 default n
343 depends on UNLZMA 352 depends on UNLZMA
344 help 353 help
345 This option reduces decompression time by about 25% at the cost of 354 This option reduces decompression time by about 25% at the cost of
diff --git a/archival/ar.c b/archival/ar.c
index acad20ff2..88236e878 100644
--- a/archival/ar.c
+++ b/archival/ar.c
@@ -28,7 +28,7 @@
28//usage: "\n -v Verbose" 28//usage: "\n -v Verbose"
29 29
30#include "libbb.h" 30#include "libbb.h"
31#include "archive.h" 31#include "bb_archive.h"
32#include "ar.h" 32#include "ar.h"
33 33
34#if ENABLE_FEATURE_AR_CREATE 34#if ENABLE_FEATURE_AR_CREATE
diff --git a/archival/bbunzip.c b/archival/bbunzip.c
index 0b0d84994..c96e5396a 100644
--- a/archival/bbunzip.c
+++ b/archival/bbunzip.c
@@ -5,7 +5,7 @@
5 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 5 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
6 */ 6 */
7#include "libbb.h" 7#include "libbb.h"
8#include "archive.h" 8#include "bb_archive.h"
9 9
10enum { 10enum {
11 OPT_STDOUT = 1 << 0, 11 OPT_STDOUT = 1 << 0,
@@ -103,7 +103,9 @@ int FAST_FUNC bbunpack(char **argv,
103 status = unpacker(&info); 103 status = unpacker(&info);
104 if (status < 0) 104 if (status < 0)
105 exitcode = 1; 105 exitcode = 1;
106 xclose(STDOUT_FILENO); /* with error check! */ 106
107 if (!(option_mask32 & OPT_STDOUT))
108 xclose(STDOUT_FILENO); /* with error check! */
107 109
108 if (filename) { 110 if (filename) {
109 char *del = new_name; 111 char *del = new_name;
@@ -145,6 +147,9 @@ int FAST_FUNC bbunpack(char **argv,
145 } 147 }
146 } while (*argv && *++argv); 148 } while (*argv && *++argv);
147 149
150 if (option_mask32 & OPT_STDOUT)
151 xclose(STDOUT_FILENO); /* with error check! */
152
148 return exitcode; 153 return exitcode;
149} 154}
150 155
diff --git a/archival/bzip2.c b/archival/bzip2.c
index e39d7f704..0716fa89b 100644
--- a/archival/bzip2.c
+++ b/archival/bzip2.c
@@ -17,9 +17,9 @@
17//usage: "\n -f Force" 17//usage: "\n -f Force"
18 18
19#include "libbb.h" 19#include "libbb.h"
20#include "archive.h" 20#include "bb_archive.h"
21 21
22#define CONFIG_BZIP2_FEATURE_SPEED 1 22#define CONFIG_BZIP2_FAST 1
23 23
24/* Speed test: 24/* Speed test:
25 * Compiled with gcc 4.2.1, run on Athlon 64 1800 MHz (512K L2 cache). 25 * Compiled with gcc 4.2.1, run on Athlon 64 1800 MHz (512K L2 cache).
@@ -27,7 +27,7 @@
27 * (time to compress gcc-4.2.1.tar is 126.4% compared to bbox). 27 * (time to compress gcc-4.2.1.tar is 126.4% compared to bbox).
28 * At SPEED 5 difference is 32.7%. 28 * At SPEED 5 difference is 32.7%.
29 * 29 *
30 * Test run of all CONFIG_BZIP2_FEATURE_SPEED values on a 11Mb text file: 30 * Test run of all CONFIG_BZIP2_FAST values on a 11Mb text file:
31 * Size Time (3 runs) 31 * Size Time (3 runs)
32 * 0: 10828 4.145 4.146 4.148 32 * 0: 10828 4.145 4.146 4.148
33 * 1: 11097 3.845 3.860 3.861 33 * 1: 11097 3.845 3.860 3.861
diff --git a/archival/cpio.c b/archival/cpio.c
index 9674a046b..c2a5b8ab9 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -12,7 +12,7 @@
12 * 12 *
13 */ 13 */
14#include "libbb.h" 14#include "libbb.h"
15#include "archive.h" 15#include "bb_archive.h"
16 16
17//usage:#define cpio_trivial_usage 17//usage:#define cpio_trivial_usage
18//usage: "[-dmvu] [-F FILE]" IF_FEATURE_CPIO_O(" [-H newc]") 18//usage: "[-dmvu] [-F FILE]" IF_FEATURE_CPIO_O(" [-H newc]")
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 2a6a7b3bf..bf9e9992c 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -57,7 +57,7 @@
57 57
58#include "libbb.h" 58#include "libbb.h"
59#include <fnmatch.h> 59#include <fnmatch.h>
60#include "archive.h" 60#include "bb_archive.h"
61 61
62/* note: if you vary hash_prime sizes be aware, 62/* note: if you vary hash_prime sizes be aware,
63 * 1) tweaking these will have a big effect on how much memory this program uses. 63 * 1) tweaking these will have a big effect on how much memory this program uses.
diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c
index 5d814d7ef..a04ec9407 100644
--- a/archival/dpkg_deb.c
+++ b/archival/dpkg_deb.c
@@ -19,7 +19,7 @@
19//usage: "$ dpkg-deb -X ./busybox_0.48-1_i386.deb /tmp\n" 19//usage: "$ dpkg-deb -X ./busybox_0.48-1_i386.deb /tmp\n"
20 20
21#include "libbb.h" 21#include "libbb.h"
22#include "archive.h" 22#include "bb_archive.h"
23 23
24#define DPKG_DEB_OPT_CONTENTS 1 24#define DPKG_DEB_OPT_CONTENTS 1
25#define DPKG_DEB_OPT_CONTROL 2 25#define DPKG_DEB_OPT_CONTROL 2
diff --git a/archival/gzip.c b/archival/gzip.c
index 507f5b151..f590fffa5 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -55,7 +55,7 @@ aa: 85.1% -- replaced with aa.gz
55//usage: "-rw-rw-r-- 1 andersen andersen 554058 Apr 14 17:49 /tmp/busybox.tar.gz\n" 55//usage: "-rw-rw-r-- 1 andersen andersen 554058 Apr 14 17:49 /tmp/busybox.tar.gz\n"
56 56
57#include "libbb.h" 57#include "libbb.h"
58#include "archive.h" 58#include "bb_archive.h"
59 59
60 60
61/* =========================================================================== 61/* ===========================================================================
@@ -81,7 +81,15 @@ aa: 85.1% -- replaced with aa.gz
81 81
82/* =========================================================================== 82/* ===========================================================================
83 */ 83 */
84#define SMALL_MEM 84#if CONFIG_GZIP_FAST == 0
85# define SMALL_MEM
86#elif CONFIG_GZIP_FAST == 1
87# define MEDIUM_MEM
88#elif CONFIG_GZIP_FAST == 2
89# define BIG_MEM
90#else
91# error "Invalid CONFIG_GZIP_FAST value"
92#endif
85 93
86#ifndef INBUFSIZ 94#ifndef INBUFSIZ
87# ifdef SMALL_MEM 95# ifdef SMALL_MEM
diff --git a/archival/libarchive/bz/blocksort.c b/archival/libarchive/bz/blocksort.c
index f70c3701d..e600cb7a7 100644
--- a/archival/libarchive/bz/blocksort.c
+++ b/archival/libarchive/bz/blocksort.c
@@ -385,7 +385,7 @@ int mainGtU(
385 * but speeds up compression 10% overall 385 * but speeds up compression 10% overall
386 */ 386 */
387 387
388#if CONFIG_BZIP2_FEATURE_SPEED >= 1 388#if CONFIG_BZIP2_FAST >= 1
389 389
390#define TIMES_8(code) \ 390#define TIMES_8(code) \
391 code; code; code; code; \ 391 code; code; code; code; \
@@ -496,7 +496,7 @@ void mainSimpleSort(uint32_t* ptr,
496 i++; 496 i++;
497 497
498/* 1.5% overall speedup, +290 bytes */ 498/* 1.5% overall speedup, +290 bytes */
499#if CONFIG_BZIP2_FEATURE_SPEED >= 3 499#if CONFIG_BZIP2_FAST >= 3
500 /*-- copy 2 --*/ 500 /*-- copy 2 --*/
501 if (i > hi) break; 501 if (i > hi) break;
502 v = ptr[i]; 502 v = ptr[i];
@@ -750,7 +750,7 @@ void mainSort(EState* state,
750 j = block[0] << 8; 750 j = block[0] << 8;
751 i = nblock - 1; 751 i = nblock - 1;
752/* 3%, +300 bytes */ 752/* 3%, +300 bytes */
753#if CONFIG_BZIP2_FEATURE_SPEED >= 2 753#if CONFIG_BZIP2_FAST >= 2
754 for (; i >= 3; i -= 4) { 754 for (; i >= 3; i -= 4) {
755 quadrant[i] = 0; 755 quadrant[i] = 0;
756 j = (j >> 8) | (((uint16_t)block[i]) << 8); 756 j = (j >> 8) | (((uint16_t)block[i]) << 8);
@@ -787,7 +787,7 @@ void mainSort(EState* state,
787 787
788 s = block[0] << 8; 788 s = block[0] << 8;
789 i = nblock - 1; 789 i = nblock - 1;
790#if CONFIG_BZIP2_FEATURE_SPEED >= 2 790#if CONFIG_BZIP2_FAST >= 2
791 for (; i >= 3; i -= 4) { 791 for (; i >= 3; i -= 4) {
792 s = (s >> 8) | (block[i] << 8); 792 s = (s >> 8) | (block[i] << 8);
793 j = ftab[s] - 1; 793 j = ftab[s] - 1;
diff --git a/archival/libarchive/bz/bzlib_private.h b/archival/libarchive/bz/bzlib_private.h
index 6430ce407..43e674bec 100644
--- a/archival/libarchive/bz/bzlib_private.h
+++ b/archival/libarchive/bz/bzlib_private.h
@@ -183,7 +183,7 @@ typedef struct EState {
183 /* stack-saving measures: these can be local, but they are too big */ 183 /* stack-saving measures: these can be local, but they are too big */
184 int32_t sendMTFValues__code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; 184 int32_t sendMTFValues__code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
185 int32_t sendMTFValues__rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; 185 int32_t sendMTFValues__rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
186#if CONFIG_BZIP2_FEATURE_SPEED >= 5 186#if CONFIG_BZIP2_FAST >= 5
187 /* second dimension: only 3 needed; 4 makes index calculations faster */ 187 /* second dimension: only 3 needed; 4 makes index calculations faster */
188 uint32_t sendMTFValues__len_pack[BZ_MAX_ALPHA_SIZE][4]; 188 uint32_t sendMTFValues__len_pack[BZ_MAX_ALPHA_SIZE][4];
189#endif 189#endif
diff --git a/archival/libarchive/bz/compress.c b/archival/libarchive/bz/compress.c
index f93671742..e9f1afdaf 100644
--- a/archival/libarchive/bz/compress.c
+++ b/archival/libarchive/bz/compress.c
@@ -61,7 +61,7 @@ void bsFinishWrite(EState* s)
61/*---------------------------------------------------*/ 61/*---------------------------------------------------*/
62static 62static
63/* Helps only on level 5, on other levels hurts. ? */ 63/* Helps only on level 5, on other levels hurts. ? */
64#if CONFIG_BZIP2_FEATURE_SPEED >= 5 64#if CONFIG_BZIP2_FAST >= 5
65ALWAYS_INLINE 65ALWAYS_INLINE
66#endif 66#endif
67void bsW(EState* s, int32_t n, uint32_t v) 67void bsW(EState* s, int32_t n, uint32_t v)
@@ -331,7 +331,7 @@ void sendMTFValues(EState* s)
331 for (v = 0; v < alphaSize; v++) 331 for (v = 0; v < alphaSize; v++)
332 s->rfreq[t][v] = 0; 332 s->rfreq[t][v] = 0;
333 333
334#if CONFIG_BZIP2_FEATURE_SPEED >= 5 334#if CONFIG_BZIP2_FAST >= 5
335 /* 335 /*
336 * Set up an auxiliary length table which is used to fast-track 336 * Set up an auxiliary length table which is used to fast-track
337 * the common case (nGroups == 6). 337 * the common case (nGroups == 6).
@@ -361,7 +361,7 @@ void sendMTFValues(EState* s)
361 */ 361 */
362 for (t = 0; t < nGroups; t++) 362 for (t = 0; t < nGroups; t++)
363 cost[t] = 0; 363 cost[t] = 0;
364#if CONFIG_BZIP2_FEATURE_SPEED >= 5 364#if CONFIG_BZIP2_FAST >= 5
365 if (nGroups == 6 && 50 == ge-gs+1) { 365 if (nGroups == 6 && 50 == ge-gs+1) {
366 /*--- fast track the common case ---*/ 366 /*--- fast track the common case ---*/
367 register uint32_t cost01, cost23, cost45; 367 register uint32_t cost01, cost23, cost45;
@@ -420,7 +420,7 @@ void sendMTFValues(EState* s)
420 * Increment the symbol frequencies for the selected table. 420 * Increment the symbol frequencies for the selected table.
421 */ 421 */
422/* 1% faster compress. +800 bytes */ 422/* 1% faster compress. +800 bytes */
423#if CONFIG_BZIP2_FEATURE_SPEED >= 4 423#if CONFIG_BZIP2_FAST >= 4
424 if (nGroups == 6 && 50 == ge-gs+1) { 424 if (nGroups == 6 && 50 == ge-gs+1) {
425 /*--- fast track the common case ---*/ 425 /*--- fast track the common case ---*/
426#define BZ_ITUR(nn) s->rfreq[bt][mtfv[gs + (nn)]]++ 426#define BZ_ITUR(nn) s->rfreq[bt][mtfv[gs + (nn)]]++
diff --git a/archival/libarchive/bz/huffman.c b/archival/libarchive/bz/huffman.c
index 676b1af66..bbec11adb 100644
--- a/archival/libarchive/bz/huffman.c
+++ b/archival/libarchive/bz/huffman.c
@@ -48,7 +48,7 @@ in the file LICENSE.
48 48
49 49
50/* 90 bytes, 0.3% of overall compress speed */ 50/* 90 bytes, 0.3% of overall compress speed */
51#if CONFIG_BZIP2_FEATURE_SPEED >= 1 51#if CONFIG_BZIP2_FAST >= 1
52 52
53/* macro works better than inline (gcc 4.2.1) */ 53/* macro works better than inline (gcc 4.2.1) */
54#define DOWNHEAP1(heap, weight, Heap) \ 54#define DOWNHEAP1(heap, weight, Heap) \
diff --git a/archival/libarchive/data_align.c b/archival/libarchive/data_align.c
index 2e56fa8ff..a6b84a440 100644
--- a/archival/libarchive/data_align.c
+++ b/archival/libarchive/data_align.c
@@ -4,7 +4,7 @@
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
7#include "archive.h" 7#include "bb_archive.h"
8 8
9void FAST_FUNC data_align(archive_handle_t *archive_handle, unsigned boundary) 9void FAST_FUNC data_align(archive_handle_t *archive_handle, unsigned boundary)
10{ 10{
diff --git a/archival/libarchive/data_extract_all.c b/archival/libarchive/data_extract_all.c
index 1b25c8bd6..f565e5471 100644
--- a/archival/libarchive/data_extract_all.c
+++ b/archival/libarchive/data_extract_all.c
@@ -4,7 +4,7 @@
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
7#include "archive.h" 7#include "bb_archive.h"
8 8
9void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) 9void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
10{ 10{
diff --git a/archival/libarchive/data_extract_to_command.c b/archival/libarchive/data_extract_to_command.c
index 0e977049d..cc2ff7798 100644
--- a/archival/libarchive/data_extract_to_command.c
+++ b/archival/libarchive/data_extract_to_command.c
@@ -4,7 +4,7 @@
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
7#include "archive.h" 7#include "bb_archive.h"
8 8
9enum { 9enum {
10 //TAR_FILETYPE, 10 //TAR_FILETYPE,
diff --git a/archival/libarchive/data_extract_to_stdout.c b/archival/libarchive/data_extract_to_stdout.c
index 91f3f3539..f849f3b42 100644
--- a/archival/libarchive/data_extract_to_stdout.c
+++ b/archival/libarchive/data_extract_to_stdout.c
@@ -4,7 +4,7 @@
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
7#include "archive.h" 7#include "bb_archive.h"
8 8
9void FAST_FUNC data_extract_to_stdout(archive_handle_t *archive_handle) 9void FAST_FUNC data_extract_to_stdout(archive_handle_t *archive_handle)
10{ 10{
diff --git a/archival/libarchive/data_skip.c b/archival/libarchive/data_skip.c
index a055424e2..588167f01 100644
--- a/archival/libarchive/data_skip.c
+++ b/archival/libarchive/data_skip.c
@@ -4,7 +4,7 @@
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
7#include "archive.h" 7#include "bb_archive.h"
8 8
9void FAST_FUNC data_skip(archive_handle_t *archive_handle) 9void FAST_FUNC data_skip(archive_handle_t *archive_handle)
10{ 10{
diff --git a/archival/libarchive/decompress_bunzip2.c b/archival/libarchive/decompress_bunzip2.c
index 4e46e6849..c4640d489 100644
--- a/archival/libarchive/decompress_bunzip2.c
+++ b/archival/libarchive/decompress_bunzip2.c
@@ -40,7 +40,7 @@
40 */ 40 */
41 41
42#include "libbb.h" 42#include "libbb.h"
43#include "archive.h" 43#include "bb_archive.h"
44 44
45/* Constants for Huffman coding */ 45/* Constants for Huffman coding */
46#define MAX_GROUPS 6 46#define MAX_GROUPS 6
@@ -752,7 +752,14 @@ unpack_bz2_stream(int src_fd, int dst_fd)
752 } 752 }
753 } 753 }
754 754
755 if (i != RETVAL_LAST_BLOCK) { 755 if (i != RETVAL_LAST_BLOCK
756 /* Observed case when i == RETVAL_OK:
757 * "bzcat z.bz2", where "z.bz2" is a bzipped zero-length file
758 * (to be exact, z.bz2 is exactly these 14 bytes:
759 * 42 5a 68 39 17 72 45 38 50 90 00 00 00 00).
760 */
761 && i != RETVAL_OK
762 ) {
756 bb_error_msg("bunzip error %d", i); 763 bb_error_msg("bunzip error %d", i);
757 break; 764 break;
758 } 765 }
diff --git a/archival/libarchive/decompress_uncompress.c b/archival/libarchive/decompress_uncompress.c
index 44d894244..c6040d04b 100644
--- a/archival/libarchive/decompress_uncompress.c
+++ b/archival/libarchive/decompress_uncompress.c
@@ -25,7 +25,7 @@
25 */ 25 */
26 26
27#include "libbb.h" 27#include "libbb.h"
28#include "archive.h" 28#include "bb_archive.h"
29 29
30 30
31/* Default input buffer size */ 31/* Default input buffer size */
@@ -163,7 +163,8 @@ unpack_Z_stream(int fd_in, int fd_out)
163 163
164 if (insize < (int) (IBUFSIZ + 64) - IBUFSIZ) { 164 if (insize < (int) (IBUFSIZ + 64) - IBUFSIZ) {
165 rsize = safe_read(fd_in, inbuf + insize, IBUFSIZ); 165 rsize = safe_read(fd_in, inbuf + insize, IBUFSIZ);
166//error check?? 166 if (rsize < 0)
167 bb_error_msg_and_die(bb_msg_read_error);
167 insize += rsize; 168 insize += rsize;
168 } 169 }
169 170
@@ -195,6 +196,8 @@ unpack_Z_stream(int fd_in, int fd_out)
195 196
196 197
197 if (oldcode == -1) { 198 if (oldcode == -1) {
199 if (code >= 256)
200 bb_error_msg_and_die("corrupted data"); /* %ld", code); */
198 oldcode = code; 201 oldcode = code;
199 finchar = (int) oldcode; 202 finchar = (int) oldcode;
200 outbuf[outpos++] = (unsigned char) finchar; 203 outbuf[outpos++] = (unsigned char) finchar;
@@ -239,6 +242,8 @@ unpack_Z_stream(int fd_in, int fd_out)
239 242
240 /* Generate output characters in reverse order */ 243 /* Generate output characters in reverse order */
241 while ((long) code >= (long) 256) { 244 while ((long) code >= (long) 256) {
245 if (stackp <= &htabof(0))
246 bb_error_msg_and_die("corrupted data");
242 *--stackp = tab_suffixof(code); 247 *--stackp = tab_suffixof(code);
243 code = tab_prefixof(code); 248 code = tab_prefixof(code);
244 } 249 }
@@ -263,8 +268,7 @@ unpack_Z_stream(int fd_in, int fd_out)
263 } 268 }
264 269
265 if (outpos >= OBUFSIZ) { 270 if (outpos >= OBUFSIZ) {
266 full_write(fd_out, outbuf, outpos); 271 xwrite(fd_out, outbuf, outpos);
267//error check??
268 IF_DESKTOP(total_written += outpos;) 272 IF_DESKTOP(total_written += outpos;)
269 outpos = 0; 273 outpos = 0;
270 } 274 }
@@ -292,8 +296,7 @@ unpack_Z_stream(int fd_in, int fd_out)
292 } while (rsize > 0); 296 } while (rsize > 0);
293 297
294 if (outpos > 0) { 298 if (outpos > 0) {
295 full_write(fd_out, outbuf, outpos); 299 xwrite(fd_out, outbuf, outpos);
296//error check??
297 IF_DESKTOP(total_written += outpos;) 300 IF_DESKTOP(total_written += outpos;)
298 } 301 }
299 302
diff --git a/archival/libarchive/decompress_unlzma.c b/archival/libarchive/decompress_unlzma.c
index a04714341..3631b50cc 100644
--- a/archival/libarchive/decompress_unlzma.c
+++ b/archival/libarchive/decompress_unlzma.c
@@ -9,7 +9,7 @@
9 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 9 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
10 */ 10 */
11#include "libbb.h" 11#include "libbb.h"
12#include "archive.h" 12#include "bb_archive.h"
13 13
14#if ENABLE_FEATURE_LZMA_FAST 14#if ENABLE_FEATURE_LZMA_FAST
15# define speed_inline ALWAYS_INLINE 15# define speed_inline ALWAYS_INLINE
diff --git a/archival/libarchive/decompress_unxz.c b/archival/libarchive/decompress_unxz.c
index e90dfb06f..3e5d4edca 100644
--- a/archival/libarchive/decompress_unxz.c
+++ b/archival/libarchive/decompress_unxz.c
@@ -10,7 +10,7 @@
10 * Licensed under GPLv2, see file LICENSE in this source tree. 10 * Licensed under GPLv2, see file LICENSE in this source tree.
11 */ 11 */
12#include "libbb.h" 12#include "libbb.h"
13#include "archive.h" 13#include "bb_archive.h"
14 14
15#define XZ_FUNC FAST_FUNC 15#define XZ_FUNC FAST_FUNC
16#define XZ_EXTERN static 16#define XZ_EXTERN static
diff --git a/archival/libarchive/decompress_unzip.c b/archival/libarchive/decompress_unzip.c
index a29eef837..aa5d22d0a 100644
--- a/archival/libarchive/decompress_unzip.c
+++ b/archival/libarchive/decompress_unzip.c
@@ -35,7 +35,7 @@
35 35
36#include <setjmp.h> 36#include <setjmp.h>
37#include "libbb.h" 37#include "libbb.h"
38#include "archive.h" 38#include "bb_archive.h"
39 39
40typedef struct huft_t { 40typedef struct huft_t {
41 unsigned char e; /* number of extra bits or operation */ 41 unsigned char e; /* number of extra bits or operation */
diff --git a/archival/libarchive/filter_accept_all.c b/archival/libarchive/filter_accept_all.c
index e69deb679..c33f7d3e3 100644
--- a/archival/libarchive/filter_accept_all.c
+++ b/archival/libarchive/filter_accept_all.c
@@ -6,7 +6,7 @@
6 */ 6 */
7 7
8#include "libbb.h" 8#include "libbb.h"
9#include "archive.h" 9#include "bb_archive.h"
10 10
11/* Accept any non-null name, its not really a filter at all */ 11/* Accept any non-null name, its not really a filter at all */
12char FAST_FUNC filter_accept_all(archive_handle_t *archive_handle) 12char FAST_FUNC filter_accept_all(archive_handle_t *archive_handle)
diff --git a/archival/libarchive/filter_accept_list.c b/archival/libarchive/filter_accept_list.c
index a7640af79..a2d4b23e9 100644
--- a/archival/libarchive/filter_accept_list.c
+++ b/archival/libarchive/filter_accept_list.c
@@ -6,7 +6,7 @@
6 */ 6 */
7 7
8#include "libbb.h" 8#include "libbb.h"
9#include "archive.h" 9#include "bb_archive.h"
10 10
11/* 11/*
12 * Accept names that are in the accept list, ignoring reject list. 12 * Accept names that are in the accept list, ignoring reject list.
diff --git a/archival/libarchive/filter_accept_list_reassign.c b/archival/libarchive/filter_accept_list_reassign.c
index d80f71668..3d19abe44 100644
--- a/archival/libarchive/filter_accept_list_reassign.c
+++ b/archival/libarchive/filter_accept_list_reassign.c
@@ -6,7 +6,7 @@
6 */ 6 */
7 7
8#include "libbb.h" 8#include "libbb.h"
9#include "archive.h" 9#include "bb_archive.h"
10 10
11/* Built and used only if ENABLE_DPKG || ENABLE_DPKG_DEB */ 11/* Built and used only if ENABLE_DPKG || ENABLE_DPKG_DEB */
12 12
diff --git a/archival/libarchive/filter_accept_reject_list.c b/archival/libarchive/filter_accept_reject_list.c
index 3e86cca65..39c811337 100644
--- a/archival/libarchive/filter_accept_reject_list.c
+++ b/archival/libarchive/filter_accept_reject_list.c
@@ -6,7 +6,7 @@
6 */ 6 */
7 7
8#include "libbb.h" 8#include "libbb.h"
9#include "archive.h" 9#include "bb_archive.h"
10 10
11/* 11/*
12 * Accept names that are in the accept list and not in the reject list 12 * Accept names that are in the accept list and not in the reject list
diff --git a/archival/libarchive/find_list_entry.c b/archival/libarchive/find_list_entry.c
index 5efd1af2e..56032c65a 100644
--- a/archival/libarchive/find_list_entry.c
+++ b/archival/libarchive/find_list_entry.c
@@ -7,7 +7,7 @@
7 7
8#include <fnmatch.h> 8#include <fnmatch.h>
9#include "libbb.h" 9#include "libbb.h"
10#include "archive.h" 10#include "bb_archive.h"
11 11
12/* Find a string in a shell pattern list */ 12/* Find a string in a shell pattern list */
13const llist_t* FAST_FUNC find_list_entry(const llist_t *list, const char *filename) 13const llist_t* FAST_FUNC find_list_entry(const llist_t *list, const char *filename)
diff --git a/archival/libarchive/get_header_ar.c b/archival/libarchive/get_header_ar.c
index df603b111..23c412496 100644
--- a/archival/libarchive/get_header_ar.c
+++ b/archival/libarchive/get_header_ar.c
@@ -5,7 +5,7 @@
5 */ 5 */
6 6
7#include "libbb.h" 7#include "libbb.h"
8#include "archive.h" 8#include "bb_archive.h"
9#include "ar.h" 9#include "ar.h"
10 10
11static unsigned read_num(const char *str, int base) 11static unsigned read_num(const char *str, int base)
diff --git a/archival/libarchive/get_header_cpio.c b/archival/libarchive/get_header_cpio.c
index 3d99b492a..1a0058b63 100644
--- a/archival/libarchive/get_header_cpio.c
+++ b/archival/libarchive/get_header_cpio.c
@@ -5,7 +5,7 @@
5 */ 5 */
6 6
7#include "libbb.h" 7#include "libbb.h"
8#include "archive.h" 8#include "bb_archive.h"
9 9
10typedef struct hardlinks_t { 10typedef struct hardlinks_t {
11 struct hardlinks_t *next; 11 struct hardlinks_t *next;
diff --git a/archival/libarchive/get_header_tar.c b/archival/libarchive/get_header_tar.c
index 79caff55a..a63c0fb01 100644
--- a/archival/libarchive/get_header_tar.c
+++ b/archival/libarchive/get_header_tar.c
@@ -12,7 +12,7 @@
12 */ 12 */
13 13
14#include "libbb.h" 14#include "libbb.h"
15#include "archive.h" 15#include "bb_archive.h"
16 16
17typedef uint32_t aliased_uint32_t FIX_ALIASING; 17typedef uint32_t aliased_uint32_t FIX_ALIASING;
18typedef off_t aliased_off_t FIX_ALIASING; 18typedef off_t aliased_off_t FIX_ALIASING;
@@ -79,10 +79,10 @@ static unsigned long long getOctal(char *str, int len)
79 * 79 *
80 * NB: tarballs with NEGATIVE unix times encoded that way were seen! 80 * NB: tarballs with NEGATIVE unix times encoded that way were seen!
81 */ 81 */
82 v = first; 82 /* Sign-extend 7bit 'first' to 64bit 'v' (that is, using 6th bit as sign): */
83 /* Sign-extend using 6th bit: */ 83 first <<= 1;
84 v <<= sizeof(unsigned long long)*8 - 7; 84 first >>= 1; /* now 7th bit = 6th bit */
85 v = (long long)v >> (sizeof(unsigned long long)*8 - 7); 85 v = first; /* sign-extend 8 bits to 64 */
86 while (--len != 0) 86 while (--len != 0)
87 v = (v << 8) + (unsigned char) *str++; 87 v = (v << 8) + (unsigned char) *str++;
88 } 88 }
diff --git a/archival/libarchive/get_header_tar_bz2.c b/archival/libarchive/get_header_tar_bz2.c
index 60d32069f..e012dec3b 100644
--- a/archival/libarchive/get_header_tar_bz2.c
+++ b/archival/libarchive/get_header_tar_bz2.c
@@ -4,7 +4,7 @@
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
7#include "archive.h" 7#include "bb_archive.h"
8 8
9char FAST_FUNC get_header_tar_bz2(archive_handle_t *archive_handle) 9char FAST_FUNC get_header_tar_bz2(archive_handle_t *archive_handle)
10{ 10{
diff --git a/archival/libarchive/get_header_tar_gz.c b/archival/libarchive/get_header_tar_gz.c
index 889fed0d9..b9679b0bd 100644
--- a/archival/libarchive/get_header_tar_gz.c
+++ b/archival/libarchive/get_header_tar_gz.c
@@ -4,7 +4,7 @@
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
7#include "archive.h" 7#include "bb_archive.h"
8 8
9char FAST_FUNC get_header_tar_gz(archive_handle_t *archive_handle) 9char FAST_FUNC get_header_tar_gz(archive_handle_t *archive_handle)
10{ 10{
diff --git a/archival/libarchive/get_header_tar_lzma.c b/archival/libarchive/get_header_tar_lzma.c
index da08e0c72..666700729 100644
--- a/archival/libarchive/get_header_tar_lzma.c
+++ b/archival/libarchive/get_header_tar_lzma.c
@@ -7,7 +7,7 @@
7 */ 7 */
8 8
9#include "libbb.h" 9#include "libbb.h"
10#include "archive.h" 10#include "bb_archive.h"
11 11
12char FAST_FUNC get_header_tar_lzma(archive_handle_t *archive_handle) 12char FAST_FUNC get_header_tar_lzma(archive_handle_t *archive_handle)
13{ 13{
diff --git a/archival/libarchive/header_list.c b/archival/libarchive/header_list.c
index c4fc75f38..0621aa406 100644
--- a/archival/libarchive/header_list.c
+++ b/archival/libarchive/header_list.c
@@ -3,7 +3,7 @@
3 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 3 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
4 */ 4 */
5#include "libbb.h" 5#include "libbb.h"
6#include "archive.h" 6#include "bb_archive.h"
7 7
8void FAST_FUNC header_list(const file_header_t *file_header) 8void FAST_FUNC header_list(const file_header_t *file_header)
9{ 9{
diff --git a/archival/libarchive/header_skip.c b/archival/libarchive/header_skip.c
index 2bfc5253c..f5987bfe2 100644
--- a/archival/libarchive/header_skip.c
+++ b/archival/libarchive/header_skip.c
@@ -3,7 +3,7 @@
3 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 3 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
4 */ 4 */
5#include "libbb.h" 5#include "libbb.h"
6#include "archive.h" 6#include "bb_archive.h"
7 7
8void FAST_FUNC header_skip(const file_header_t *file_header UNUSED_PARAM) 8void FAST_FUNC header_skip(const file_header_t *file_header UNUSED_PARAM)
9{ 9{
diff --git a/archival/libarchive/header_verbose_list.c b/archival/libarchive/header_verbose_list.c
index bc4e4154b..87dd82136 100644
--- a/archival/libarchive/header_verbose_list.c
+++ b/archival/libarchive/header_verbose_list.c
@@ -4,7 +4,7 @@
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
7#include "archive.h" 7#include "bb_archive.h"
8 8
9void FAST_FUNC header_verbose_list(const file_header_t *file_header) 9void FAST_FUNC header_verbose_list(const file_header_t *file_header)
10{ 10{
diff --git a/archival/libarchive/init_handle.c b/archival/libarchive/init_handle.c
index 6644ea13b..cbae06ac3 100644
--- a/archival/libarchive/init_handle.c
+++ b/archival/libarchive/init_handle.c
@@ -4,7 +4,7 @@
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
7#include "archive.h" 7#include "bb_archive.h"
8 8
9archive_handle_t* FAST_FUNC init_handle(void) 9archive_handle_t* FAST_FUNC init_handle(void)
10{ 10{
diff --git a/archival/libarchive/open_transformer.c b/archival/libarchive/open_transformer.c
index 26ae565f5..aa8c1021c 100644
--- a/archival/libarchive/open_transformer.c
+++ b/archival/libarchive/open_transformer.c
@@ -4,7 +4,7 @@
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
7#include "archive.h" 7#include "bb_archive.h"
8 8
9/* transformer(), more than meets the eye */ 9/* transformer(), more than meets the eye */
10/* 10/*
diff --git a/archival/libarchive/seek_by_jump.c b/archival/libarchive/seek_by_jump.c
index 7c2c52ae1..4fcd99ac8 100644
--- a/archival/libarchive/seek_by_jump.c
+++ b/archival/libarchive/seek_by_jump.c
@@ -4,7 +4,7 @@
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
7#include "archive.h" 7#include "bb_archive.h"
8 8
9void FAST_FUNC seek_by_jump(int fd, off_t amount) 9void FAST_FUNC seek_by_jump(int fd, off_t amount)
10{ 10{
diff --git a/archival/libarchive/seek_by_read.c b/archival/libarchive/seek_by_read.c
index ad931a8de..c0fde9660 100644
--- a/archival/libarchive/seek_by_read.c
+++ b/archival/libarchive/seek_by_read.c
@@ -4,7 +4,7 @@
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
7#include "archive.h" 7#include "bb_archive.h"
8 8
9/* If we are reading through a pipe, or from stdin then we can't lseek, 9/* If we are reading through a pipe, or from stdin then we can't lseek,
10 * we must read and discard the data to skip over it. 10 * we must read and discard the data to skip over it.
diff --git a/archival/libarchive/unpack_ar_archive.c b/archival/libarchive/unpack_ar_archive.c
index 18dbfd54d..214d17e23 100644
--- a/archival/libarchive/unpack_ar_archive.c
+++ b/archival/libarchive/unpack_ar_archive.c
@@ -4,7 +4,7 @@
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
7#include "archive.h" 7#include "bb_archive.h"
8#include "ar.h" 8#include "ar.h"
9 9
10void FAST_FUNC unpack_ar_archive(archive_handle_t *ar_archive) 10void FAST_FUNC unpack_ar_archive(archive_handle_t *ar_archive)
diff --git a/archival/lzop.c b/archival/lzop.c
index 1326bd790..7e30091d9 100644
--- a/archival/lzop.c
+++ b/archival/lzop.c
@@ -51,7 +51,7 @@
51//usage: "\n -F Don't store or verify checksum" 51//usage: "\n -F Don't store or verify checksum"
52 52
53#include "libbb.h" 53#include "libbb.h"
54#include "archive.h" 54#include "bb_archive.h"
55#include "liblzo_interface.h" 55#include "liblzo_interface.h"
56 56
57/* lzo-2.03/src/lzo_ptr.h */ 57/* lzo-2.03/src/lzo_ptr.h */
diff --git a/archival/rpm.c b/archival/rpm.c
index 8174f4869..089b68983 100644
--- a/archival/rpm.c
+++ b/archival/rpm.c
@@ -20,7 +20,7 @@
20//usage: "\n -c List config files" 20//usage: "\n -c List config files"
21 21
22#include "libbb.h" 22#include "libbb.h"
23#include "archive.h" 23#include "bb_archive.h"
24#include "rpm.h" 24#include "rpm.h"
25 25
26#define RPM_CHAR_TYPE 1 26#define RPM_CHAR_TYPE 1
diff --git a/archival/rpm2cpio.c b/archival/rpm2cpio.c
index ff4a0d1b0..28b43a181 100644
--- a/archival/rpm2cpio.c
+++ b/archival/rpm2cpio.c
@@ -13,7 +13,7 @@
13//usage: "Output a cpio archive of the rpm file" 13//usage: "Output a cpio archive of the rpm file"
14 14
15#include "libbb.h" 15#include "libbb.h"
16#include "archive.h" 16#include "bb_archive.h"
17#include "rpm.h" 17#include "rpm.h"
18 18
19enum { rpm_fd = STDIN_FILENO }; 19enum { rpm_fd = STDIN_FILENO };
diff --git a/archival/tar.c b/archival/tar.c
index e7963b0b4..2b752f640 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -44,7 +44,7 @@
44 44
45#include <fnmatch.h> 45#include <fnmatch.h>
46#include "libbb.h" 46#include "libbb.h"
47#include "archive.h" 47#include "bb_archive.h"
48/* FIXME: Stop using this non-standard feature */ 48/* FIXME: Stop using this non-standard feature */
49#ifndef FNM_LEADING_DIR 49#ifndef FNM_LEADING_DIR
50# define FNM_LEADING_DIR 0 50# define FNM_LEADING_DIR 0
diff --git a/archival/unzip.c b/archival/unzip.c
index 4fa729326..3a11f78a5 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -32,7 +32,7 @@
32//usage: "\n -d DIR Extract files into DIR" 32//usage: "\n -d DIR Extract files into DIR"
33 33
34#include "libbb.h" 34#include "libbb.h"
35#include "archive.h" 35#include "bb_archive.h"
36 36
37enum { 37enum {
38#if BB_BIG_ENDIAN 38#if BB_BIG_ENDIAN
@@ -235,7 +235,7 @@ static void unzip_create_leading_dirs(const char *fn)
235 /* Create all leading directories */ 235 /* Create all leading directories */
236 char *name = xstrdup(fn); 236 char *name = xstrdup(fn);
237 if (bb_make_directory(dirname(name), 0777, FILEUTILS_RECUR)) { 237 if (bb_make_directory(dirname(name), 0777, FILEUTILS_RECUR)) {
238 bb_error_msg_and_die("exiting"); /* bb_make_directory is noisy */ 238 xfunc_die(); /* bb_make_directory is noisy */
239 } 239 }
240 free(name); 240 free(name);
241} 241}
@@ -595,7 +595,7 @@ int unzip_main(int argc, char **argv)
595 } 595 }
596 unzip_create_leading_dirs(dst_fn); 596 unzip_create_leading_dirs(dst_fn);
597 if (bb_make_directory(dst_fn, dir_mode, 0)) { 597 if (bb_make_directory(dst_fn, dir_mode, 0)) {
598 bb_error_msg_and_die("exiting"); 598 xfunc_die();
599 } 599 }
600 } else { 600 } else {
601 if (!S_ISDIR(stat_buf.st_mode)) { 601 if (!S_ISDIR(stat_buf.st_mode)) {
@@ -619,6 +619,7 @@ int unzip_main(int argc, char **argv)
619 i = 'y'; 619 i = 'y';
620 } else { 620 } else {
621 printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn); 621 printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn);
622 fflush_all();
622 if (!fgets(key_buf, sizeof(key_buf), stdin)) { 623 if (!fgets(key_buf, sizeof(key_buf), stdin)) {
623 bb_perror_msg_and_die("can't read input"); 624 bb_perror_msg_and_die("can't read input");
624 } 625 }