wok-current diff busybox/stuff/busybox-1.22-xz.u @ rev 15770

Up tazinst-gui (3.94)
author Dominique Corbex <domcox@slitaz.org>
date Tue Jan 07 21:52:00 2014 +0100 (2014-01-07)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/busybox/stuff/busybox-1.22-xz.u	Tue Jan 07 21:52:00 2014 +0100
     1.3 @@ -0,0 +1,84 @@
     1.4 +--- busybox-1.21.0/archival/libarchive/decompress_unxz.c
     1.5 ++++ busybox-1.21.0/archival/libarchive/decompress_unxz.c
     1.6 +@@ -40,6 +40,7 @@ static uint32_t xz_crc32(const uint8_t *
     1.7 + IF_DESKTOP(long long) int FAST_FUNC
     1.8 + unpack_xz_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
     1.9 + {
    1.10 ++	enum xz_ret xz_result;
    1.11 + 	struct xz_buf iobuf;
    1.12 + 	struct xz_dec *state;
    1.13 + 	unsigned char *membuf;
    1.14 +@@ -63,9 +64,8 @@ unpack_xz_stream(transformer_aux_data_t
    1.15 + 	/* Limit memory usage to about 64 MiB. */
    1.16 + 	state = xz_dec_init(XZ_DYNALLOC, 64*1024*1024);
    1.17 + 
    1.18 ++	xz_result = X_OK;
    1.19 + 	while (1) {
    1.20 +-		enum xz_ret r;
    1.21 +-
    1.22 + 		if (iobuf.in_pos == iobuf.in_size) {
    1.23 + 			int rd = safe_read(src_fd, membuf, BUFSIZ);
    1.24 + 			if (rd < 0) {
    1.25 +@@ -73,28 +73,57 @@ unpack_xz_stream(transformer_aux_data_t
    1.26 + 				total = -1;
    1.27 + 				break;
    1.28 + 			}
    1.29 ++			if (rd == 0 && xz_result == XZ_STREAM_END)
    1.30 ++				break;
    1.31 + 			iobuf.in_size = rd;
    1.32 + 			iobuf.in_pos = 0;
    1.33 + 		}
    1.34 ++		if (xz_result == XZ_STREAM_END) {
    1.35 ++			/*
    1.36 ++			 * Try to start decoding next concatenated stream.
    1.37 ++			 * Stream padding must always be a multiple of four
    1.38 ++			 * bytes to preserve four-byte alignment. To keep the
    1.39 ++			 * code slightly smaller, we aren't as strict here as
    1.40 ++			 * the .xz spec requires. We just skip all zero-bytes
    1.41 ++			 * without checking the alignment and thus can accept
    1.42 ++			 * files that aren't valid, e.g. the XZ utils test
    1.43 ++			 * files bad-0pad-empty.xz and bad-0catpad-empty.xz.
    1.44 ++			 */
    1.45 ++			do {
    1.46 ++				if (membuf[iobuf.in_pos] != 0) {
    1.47 ++					xz_dec_reset(state);
    1.48 ++					goto do_run;
    1.49 ++				}
    1.50 ++				iobuf.in_pos++;
    1.51 ++			} while (iobuf.in_pos < iobuf.in_size);
    1.52 ++		}
    1.53 ++ do_run:
    1.54 + //		bb_error_msg(">in pos:%d size:%d out pos:%d size:%d",
    1.55 + //				iobuf.in_pos, iobuf.in_size, iobuf.out_pos, iobuf.out_size);
    1.56 +-		r = xz_dec_run(state, &iobuf);
    1.57 ++		xz_result = xz_dec_run(state, &iobuf);
    1.58 + //		bb_error_msg("<in pos:%d size:%d out pos:%d size:%d r:%d",
    1.59 +-//				iobuf.in_pos, iobuf.in_size, iobuf.out_pos, iobuf.out_size, r);
    1.60 ++//				iobuf.in_pos, iobuf.in_size, iobuf.out_pos, iobuf.out_size, xz_result);
    1.61 + 		if (iobuf.out_pos) {
    1.62 + 			xwrite(dst_fd, iobuf.out, iobuf.out_pos);
    1.63 + 			IF_DESKTOP(total += iobuf.out_pos;)
    1.64 + 			iobuf.out_pos = 0;
    1.65 + 		}
    1.66 +-		if (r == XZ_STREAM_END) {
    1.67 +-			break;
    1.68 ++		if (xz_result == XZ_STREAM_END) {
    1.69 ++			/*
    1.70 ++			 * Can just "break;" here, if not for concatenated
    1.71 ++			 * .xz streams.
    1.72 ++			 * Checking for padding may require buffer
    1.73 ++			 * replenishment. Can't do it here.
    1.74 ++			 */
    1.75 ++			continue;
    1.76 + 		}
    1.77 +-		if (r != XZ_OK && r != XZ_UNSUPPORTED_CHECK) {
    1.78 ++		if (xz_result != XZ_OK && xz_result != XZ_UNSUPPORTED_CHECK) {
    1.79 + 			bb_error_msg("corrupted data");
    1.80 + 			total = -1;
    1.81 + 			break;
    1.82 + 		}
    1.83 + 	}
    1.84 ++
    1.85 + 	xz_dec_end(state);
    1.86 + 	free(membuf);
    1.87 +