Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (10 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/archival/libarchive/decompress_uncompress.c

    r2725 r3232  
    2626
    2727#include "libbb.h"
    28 #include "archive.h"
     28#include "bb_archive.h"
    2929
    3030
     
    7474
    7575IF_DESKTOP(long long) int FAST_FUNC
    76 unpack_Z_stream(int fd_in, int fd_out)
     76unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
    7777{
    7878    IF_DESKTOP(long long total_written = 0;)
    7979    IF_DESKTOP(long long) int retval = -1;
    8080    unsigned char *stackp;
    81     long code;
    8281    int finchar;
    8382    long oldcode;
     
    104103    int block_mode; /* = BLOCK_MODE; */
    105104
     105    if (check_signature16(aux, src_fd, COMPRESS_MAGIC))
     106        return -1;
     107
    106108    inbuf = xzalloc(IBUFSIZ + 64);
    107109    outbuf = xzalloc(OBUFSIZ + 2048);
    108     htab = xzalloc(HSIZE);  /* wsn't zeroed out before, maybe can xmalloc? */
     110    htab = xzalloc(HSIZE);  /* wasn't zeroed out before, maybe can xmalloc? */
    109111    codetab = xzalloc(HSIZE * sizeof(codetab[0]));
    110112
     
    113115    /* xread isn't good here, we have to return - caller may want
    114116     * 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) {
    116118        bb_error_msg("short read");
    117119        goto err;
     
    141143    /*clear_tab_prefixof(); - done by xzalloc */
    142144
    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;
    145149    }
    146150
     
    163167
    164168        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);
    167172            insize += rsize;
    168173        }
     
    172177
    173178        while (inbits > posbits) {
     179            long code;
     180
    174181            if (free_ent > maxcode) {
    175182                posbits =
     
    188195            {
    189196                unsigned char *p = &inbuf[posbits >> 3];
    190 
    191                 code = ((((long) (p[0])) | ((long) (p[1]) << 8) |
    192                         ((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
     197                code = ((p[0]
     198                    | ((long) (p[1]) << 8)
     199                    | ((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
    193200            }
    194201            posbits += n_bits;
    195202
    196 
    197203            if (oldcode == -1) {
     204                if (code >= 256)
     205                    bb_error_msg_and_die("corrupted data"); /* %ld", code); */
    198206                oldcode = code;
    199207                finchar = (int) oldcode;
     
    221229            if (code >= free_ent) {
    222230                if (code > free_ent) {
     231/*
    223232                    unsigned char *p;
    224233
    225234                    posbits -= n_bits;
    226235                    p = &inbuf[posbits >> 3];
    227 
    228236                    bb_error_msg
    229237                        ("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*/
    232241                    bb_error_msg("corrupted data");
    233242                    goto err;
     
    239248
    240249            /* 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");
    242253                *--stackp = tab_suffixof(code);
    243254                code = tab_prefixof(code);
     
    264275
    265276                        if (outpos >= OBUFSIZ) {
    266                             full_write(fd_out, outbuf, outpos);
    267 //error check??
     277                            xwrite(dst_fd, outbuf, outpos);
    268278                            IF_DESKTOP(total_written += outpos;)
    269279                            outpos = 0;
     
    279289
    280290            /* 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++;
    286295            }
    287296
     
    293302
    294303    if (outpos > 0) {
    295         full_write(fd_out, outbuf, outpos);
    296 //error check??
     304        xwrite(dst_fd, outbuf, outpos);
    297305        IF_DESKTOP(total_written += outpos;)
    298306    }
Note: See TracChangeset for help on using the changeset viewer.