aboutsummaryrefslogtreecommitdiff
path: root/archival/libarchive
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2014-03-11 19:40:20 +0000
committerRon Yorston <rmy@pobox.com>2014-03-11 19:40:20 +0000
commitdec20ad781163656832c571d52d0303c67ea8c09 (patch)
tree830a27bc8f2383d4ba50680f5d6fac1ec5c96b6a /archival/libarchive
parent0a2a7b55a9212d8fc708fd564407e5505b5e8363 (diff)
parent69f9567de28976cfbc7b216c46aa391ce82bd3b7 (diff)
downloadbusybox-w32-dec20ad781163656832c571d52d0303c67ea8c09.tar.gz
busybox-w32-dec20ad781163656832c571d52d0303c67ea8c09.tar.bz2
busybox-w32-dec20ad781163656832c571d52d0303c67ea8c09.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'archival/libarchive')
-rw-r--r--archival/libarchive/decompress_unlzma.c23
-rw-r--r--archival/libarchive/get_header_tar.c2
-rw-r--r--archival/libarchive/open_transformer.c10
3 files changed, 22 insertions, 13 deletions
diff --git a/archival/libarchive/decompress_unlzma.c b/archival/libarchive/decompress_unlzma.c
index ca32bd82c..3d99e1388 100644
--- a/archival/libarchive/decompress_unlzma.c
+++ b/archival/libarchive/decompress_unlzma.c
@@ -214,8 +214,6 @@ unpack_lzma_stream(transformer_aux_data_t *aux UNUSED_PARAM, int src_fd, int dst
214 uint32_t pos_state_mask; 214 uint32_t pos_state_mask;
215 uint32_t literal_pos_mask; 215 uint32_t literal_pos_mask;
216 uint16_t *p; 216 uint16_t *p;
217 int num_bits;
218 int num_probs;
219 rc_t *rc; 217 rc_t *rc;
220 int i; 218 int i;
221 uint8_t *buffer; 219 uint8_t *buffer;
@@ -239,6 +237,9 @@ unpack_lzma_stream(transformer_aux_data_t *aux UNUSED_PARAM, int src_fd, int dst
239 pos_state_mask = (1 << pb) - 1; 237 pos_state_mask = (1 << pb) - 1;
240 literal_pos_mask = (1 << lp) - 1; 238 literal_pos_mask = (1 << lp) - 1;
241 239
240 /* Example values from linux-3.3.4.tar.lzma:
241 * dict_size: 64M, dst_size: 2^64-1
242 */
242 header.dict_size = SWAP_LE32(header.dict_size); 243 header.dict_size = SWAP_LE32(header.dict_size);
243 header.dst_size = SWAP_LE64(header.dst_size); 244 header.dst_size = SWAP_LE64(header.dst_size);
244 245
@@ -247,11 +248,15 @@ unpack_lzma_stream(transformer_aux_data_t *aux UNUSED_PARAM, int src_fd, int dst
247 248
248 buffer = xmalloc(MIN(header.dst_size, header.dict_size)); 249 buffer = xmalloc(MIN(header.dst_size, header.dict_size));
249 250
250 num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp)); 251 {
251 p = xmalloc(num_probs * sizeof(*p)); 252 int num_probs;
252 num_probs += LZMA_LITERAL - LZMA_BASE_SIZE; 253
253 for (i = 0; i < num_probs; i++) 254 num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp));
254 p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1; 255 p = xmalloc(num_probs * sizeof(*p));
256 num_probs += LZMA_LITERAL - LZMA_BASE_SIZE;
257 for (i = 0; i < num_probs; i++)
258 p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1;
259 }
255 260
256 rc = rc_init(src_fd); /*, RC_BUFFER_SIZE); */ 261 rc = rc_init(src_fd); /*, RC_BUFFER_SIZE); */
257 262
@@ -310,6 +315,7 @@ unpack_lzma_stream(transformer_aux_data_t *aux UNUSED_PARAM, int src_fd, int dst
310 goto one_byte2; 315 goto one_byte2;
311#endif 316#endif
312 } else { 317 } else {
318 int num_bits;
313 int offset; 319 int offset;
314 uint16_t *prob2; 320 uint16_t *prob2;
315#define prob_len prob2 321#define prob_len prob2
@@ -440,6 +446,9 @@ unpack_lzma_stream(transformer_aux_data_t *aux UNUSED_PARAM, int src_fd, int dst
440 } 446 }
441 len--; 447 len--;
442 } while (len != 0 && buffer_pos < header.dst_size); 448 } while (len != 0 && buffer_pos < header.dst_size);
449 /* FIXME: ...........^^^^^
450 * shouldn't it be "global_pos + buffer_pos < header.dst_size"?
451 */
443 } 452 }
444 } 453 }
445 454
diff --git a/archival/libarchive/get_header_tar.c b/archival/libarchive/get_header_tar.c
index 54d910431..ba43bb073 100644
--- a/archival/libarchive/get_header_tar.c
+++ b/archival/libarchive/get_header_tar.c
@@ -243,7 +243,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
243 * or not first block (false positive, it's not .gz/.bz2!) */ 243 * or not first block (false positive, it's not .gz/.bz2!) */
244 if (lseek(archive_handle->src_fd, -i, SEEK_CUR) != 0) 244 if (lseek(archive_handle->src_fd, -i, SEEK_CUR) != 0)
245 goto err; 245 goto err;
246 if (setup_unzip_on_fd(archive_handle->src_fd, /*fail_if_not_detected:*/ 0) != 0) 246 if (setup_unzip_on_fd(archive_handle->src_fd, /*fail_if_not_compressed:*/ 0) != 0)
247 err: 247 err:
248 bb_error_msg_and_die("invalid tar magic"); 248 bb_error_msg_and_die("invalid tar magic");
249 archive_handle->offset = 0; 249 archive_handle->offset = 0;
diff --git a/archival/libarchive/open_transformer.c b/archival/libarchive/open_transformer.c
index b11bf46af..e49eab409 100644
--- a/archival/libarchive/open_transformer.c
+++ b/archival/libarchive/open_transformer.c
@@ -120,7 +120,7 @@ void FAST_FUNC open_transformer(int fd, const char *transform_prog)
120/* Used by e.g. rpm which gives us a fd without filename, 120/* Used by e.g. rpm which gives us a fd without filename,
121 * thus we can't guess the format from filename's extension. 121 * thus we can't guess the format from filename's extension.
122 */ 122 */
123int FAST_FUNC setup_unzip_on_fd(int fd, int fail_if_not_detected) 123int FAST_FUNC setup_unzip_on_fd(int fd, int fail_if_not_compressed)
124{ 124{
125 union { 125 union {
126 uint8_t b[4]; 126 uint8_t b[4];
@@ -161,7 +161,7 @@ int FAST_FUNC setup_unzip_on_fd(int fd, int fail_if_not_detected)
161 } 161 }
162 162
163 /* No known magic seen */ 163 /* No known magic seen */
164 if (fail_if_not_detected) 164 if (fail_if_not_compressed)
165 bb_error_msg_and_die("no gzip" 165 bb_error_msg_and_die("no gzip"
166 IF_FEATURE_SEAMLESS_BZ2("/bzip2") 166 IF_FEATURE_SEAMLESS_BZ2("/bzip2")
167 IF_FEATURE_SEAMLESS_XZ("/xz") 167 IF_FEATURE_SEAMLESS_XZ("/xz")
@@ -182,7 +182,7 @@ int FAST_FUNC setup_unzip_on_fd(int fd, int fail_if_not_detected)
182 return 0; 182 return 0;
183} 183}
184 184
185int FAST_FUNC open_zipped(const char *fname) 185int FAST_FUNC open_zipped(const char *fname, int fail_if_not_compressed)
186{ 186{
187 int fd; 187 int fd;
188 188
@@ -202,7 +202,7 @@ int FAST_FUNC open_zipped(const char *fname)
202 || (ENABLE_FEATURE_SEAMLESS_BZ2) 202 || (ENABLE_FEATURE_SEAMLESS_BZ2)
203 || (ENABLE_FEATURE_SEAMLESS_XZ) 203 || (ENABLE_FEATURE_SEAMLESS_XZ)
204 ) { 204 ) {
205 setup_unzip_on_fd(fd, /*fail_if_not_detected:*/ 1); 205 setup_unzip_on_fd(fd, fail_if_not_compressed);
206 } 206 }
207 207
208 return fd; 208 return fd;
@@ -215,7 +215,7 @@ void* FAST_FUNC xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_
215 int fd; 215 int fd;
216 char *image; 216 char *image;
217 217
218 fd = open_zipped(fname); 218 fd = open_zipped(fname, /*fail_if_not_compressed:*/ 0);
219 if (fd < 0) 219 if (fd < 0)
220 return NULL; 220 return NULL;
221 221