Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/archival/libarchive/decompress_uncompress.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/archival/libarchive/decompress_uncompress.c
r2725 r3232 26 26 27 27 #include "libbb.h" 28 #include " archive.h"28 #include "bb_archive.h" 29 29 30 30 … … 74 74 75 75 IF_DESKTOP(long long) int FAST_FUNC 76 unpack_Z_stream( int fd_in, int fd_out)76 unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd) 77 77 { 78 78 IF_DESKTOP(long long total_written = 0;) 79 79 IF_DESKTOP(long long) int retval = -1; 80 80 unsigned char *stackp; 81 long code;82 81 int finchar; 83 82 long oldcode; … … 104 103 int block_mode; /* = BLOCK_MODE; */ 105 104 105 if (check_signature16(aux, src_fd, COMPRESS_MAGIC)) 106 return -1; 107 106 108 inbuf = xzalloc(IBUFSIZ + 64); 107 109 outbuf = xzalloc(OBUFSIZ + 2048); 108 htab = xzalloc(HSIZE); /* w sn't zeroed out before, maybe can xmalloc? */110 htab = xzalloc(HSIZE); /* wasn't zeroed out before, maybe can xmalloc? */ 109 111 codetab = xzalloc(HSIZE * sizeof(codetab[0])); 110 112 … … 113 115 /* xread isn't good here, we have to return - caller may want 114 116 * to do some cleanup (e.g. delete incomplete unpacked file etc) */ 115 if (full_read( fd_in, inbuf, 1) != 1) {117 if (full_read(src_fd, inbuf, 1) != 1) { 116 118 bb_error_msg("short read"); 117 119 goto err; … … 141 143 /*clear_tab_prefixof(); - done by xzalloc */ 142 144 143 for (code = 255; code >= 0; --code) { 144 tab_suffixof(code) = (unsigned char) code; 145 { 146 int i; 147 for (i = 255; i >= 0; --i) 148 tab_suffixof(i) = (unsigned char) i; 145 149 } 146 150 … … 163 167 164 168 if (insize < (int) (IBUFSIZ + 64) - IBUFSIZ) { 165 rsize = safe_read(fd_in, inbuf + insize, IBUFSIZ); 166 //error check?? 169 rsize = safe_read(src_fd, inbuf + insize, IBUFSIZ); 170 if (rsize < 0) 171 bb_error_msg_and_die(bb_msg_read_error); 167 172 insize += rsize; 168 173 } … … 172 177 173 178 while (inbits > posbits) { 179 long code; 180 174 181 if (free_ent > maxcode) { 175 182 posbits = … … 188 195 { 189 196 unsigned char *p = &inbuf[posbits >> 3]; 190 191 code = ((((long) (p[0])) | ((long) (p[1]) << 8) |192 197 code = ((p[0] 198 | ((long) (p[1]) << 8) 199 | ((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask; 193 200 } 194 201 posbits += n_bits; 195 202 196 197 203 if (oldcode == -1) { 204 if (code >= 256) 205 bb_error_msg_and_die("corrupted data"); /* %ld", code); */ 198 206 oldcode = code; 199 207 finchar = (int) oldcode; … … 221 229 if (code >= free_ent) { 222 230 if (code > free_ent) { 231 /* 223 232 unsigned char *p; 224 233 225 234 posbits -= n_bits; 226 235 p = &inbuf[posbits >> 3]; 227 228 236 bb_error_msg 229 237 ("insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)", 230 insize, posbits, p[-1], p[0], p[1], p[2], p[3], 231 (posbits & 07)); 238 insize, posbits, p[-1], p[0], p[1], p[2], p[3], 239 (posbits & 07)); 240 */ 232 241 bb_error_msg("corrupted data"); 233 242 goto err; … … 239 248 240 249 /* Generate output characters in reverse order */ 241 while ((long) code >= (long) 256) { 250 while (code >= 256) { 251 if (stackp <= &htabof(0)) 252 bb_error_msg_and_die("corrupted data"); 242 253 *--stackp = tab_suffixof(code); 243 254 code = tab_prefixof(code); … … 264 275 265 276 if (outpos >= OBUFSIZ) { 266 full_write(fd_out, outbuf, outpos); 267 //error check?? 277 xwrite(dst_fd, outbuf, outpos); 268 278 IF_DESKTOP(total_written += outpos;) 269 279 outpos = 0; … … 279 289 280 290 /* Generate the new entry. */ 281 code = free_ent; 282 if (code < maxmaxcode) { 283 tab_prefixof(code) = (unsigned short) oldcode; 284 tab_suffixof(code) = (unsigned char) finchar; 285 free_ent = code + 1; 291 if (free_ent < maxmaxcode) { 292 tab_prefixof(free_ent) = (unsigned short) oldcode; 293 tab_suffixof(free_ent) = (unsigned char) finchar; 294 free_ent++; 286 295 } 287 296 … … 293 302 294 303 if (outpos > 0) { 295 full_write(fd_out, outbuf, outpos); 296 //error check?? 304 xwrite(dst_fd, outbuf, outpos); 297 305 IF_DESKTOP(total_written += outpos;) 298 306 }
Note:
See TracChangeset
for help on using the changeset viewer.