aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archival/libarchive/decompress_uncompress.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/archival/libarchive/decompress_uncompress.c b/archival/libarchive/decompress_uncompress.c
index e9bbfb9bd..4ccc8a697 100644
--- a/archival/libarchive/decompress_uncompress.c
+++ b/archival/libarchive/decompress_uncompress.c
@@ -78,7 +78,6 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
78 IF_DESKTOP(long long total_written = 0;) 78 IF_DESKTOP(long long total_written = 0;)
79 IF_DESKTOP(long long) int retval = -1; 79 IF_DESKTOP(long long) int retval = -1;
80 unsigned char *stackp; 80 unsigned char *stackp;
81 long code;
82 int finchar; 81 int finchar;
83 long oldcode; 82 long oldcode;
84 long incode; 83 long incode;
@@ -143,8 +142,10 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
143 /* As above, initialize the first 256 entries in the table. */ 142 /* As above, initialize the first 256 entries in the table. */
144 /*clear_tab_prefixof(); - done by xzalloc */ 143 /*clear_tab_prefixof(); - done by xzalloc */
145 144
146 for (code = 255; code >= 0; --code) { 145 {
147 tab_suffixof(code) = (unsigned char) code; 146 int i;
147 for (i = 255; i >= 0; --i)
148 tab_suffixof(i) = (unsigned char) i;
148 } 149 }
149 150
150 do { 151 do {
@@ -175,6 +176,8 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
175 (insize << 3) - (n_bits - 1)); 176 (insize << 3) - (n_bits - 1));
176 177
177 while (inbits > posbits) { 178 while (inbits > posbits) {
179 long code;
180
178 if (free_ent > maxcode) { 181 if (free_ent > maxcode) {
179 posbits = 182 posbits =
180 ((posbits - 1) + 183 ((posbits - 1) +
@@ -191,13 +194,12 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
191 } 194 }
192 { 195 {
193 unsigned char *p = &inbuf[posbits >> 3]; 196 unsigned char *p = &inbuf[posbits >> 3];
194 197 code = ((p[0]
195 code = ((((long) (p[0])) | ((long) (p[1]) << 8) | 198 | ((long) (p[1]) << 8)
196 ((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask; 199 | ((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
197 } 200 }
198 posbits += n_bits; 201 posbits += n_bits;
199 202
200
201 if (oldcode == -1) { 203 if (oldcode == -1) {
202 if (code >= 256) 204 if (code >= 256)
203 bb_error_msg_and_die("corrupted data"); /* %ld", code); */ 205 bb_error_msg_and_die("corrupted data"); /* %ld", code); */
@@ -244,7 +246,7 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
244 } 246 }
245 247
246 /* Generate output characters in reverse order */ 248 /* Generate output characters in reverse order */
247 while ((long) code >= (long) 256) { 249 while (code >= 256) {
248 if (stackp <= &htabof(0)) 250 if (stackp <= &htabof(0))
249 bb_error_msg_and_die("corrupted data"); 251 bb_error_msg_and_die("corrupted data");
250 *--stackp = tab_suffixof(code); 252 *--stackp = tab_suffixof(code);
@@ -285,11 +287,10 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
285 } 287 }
286 288
287 /* Generate the new entry. */ 289 /* Generate the new entry. */
288 code = free_ent; 290 if (free_ent < maxmaxcode) {
289 if (code < maxmaxcode) { 291 tab_prefixof(free_ent) = (unsigned short) oldcode;
290 tab_prefixof(code) = (unsigned short) oldcode; 292 tab_suffixof(free_ent) = (unsigned char) finchar;
291 tab_suffixof(code) = (unsigned char) finchar; 293 free_ent++;
292 free_ent = code + 1;
293 } 294 }
294 295
295 /* Remember previous code. */ 296 /* Remember previous code. */