tar et al: die if bb_copyfd_size copies less than asked for.
[oweals/busybox.git] / archival / libunarchive / decompress_unzip.c
index 989ac4fd8a9a0bd04860860d67882e3e7307d931..621d84c2d51ff97ef20fd07538fa9ffc60ed0582 100644 (file)
@@ -123,7 +123,7 @@ static unsigned int fill_bitbuffer(unsigned int bitbuffer, unsigned int *current
                bytebuffer_offset++;
                *current += 8;
        }
-       return(bitbuffer);
+       return bitbuffer;
 }
 
 /*
@@ -745,7 +745,7 @@ static int inflate_block(int *e)
 
                if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl)) != 0) {
                        if (i == 1) {
-                               bb_error_msg_and_die("Incomplete literal tree");
+                               bb_error_msg_and_die("incomplete literal tree");
                                huft_free(tl);
                        }
                        return i;       /* incomplete code set */
@@ -835,8 +835,10 @@ void inflate_cleanup(void)
        free(bytebuffer);
 }
 
-int inflate_unzip(int in, int out)
+USE_DESKTOP(long long) int
+inflate_unzip(int in, int out)
 {
+       USE_DESKTOP(long long total = 0;)
        ssize_t nwrote;
        typedef void (*sig_type) (int);
 
@@ -864,6 +866,7 @@ int inflate_unzip(int in, int out)
                        bb_perror_msg("write");
                        return -1;
                }
+               USE_DESKTOP(total += nwrote;)
                if (ret == 0) break;
        }
 
@@ -880,15 +883,17 @@ int inflate_unzip(int in, int out)
                gunzip_bb >>= 8;
                gunzip_bk -= 8;
        }
-       return 0;
+       return USE_DESKTOP(total) + 0;
 }
 
-int inflate_gunzip(int in, int out)
+USE_DESKTOP(long long) int
+inflate_gunzip(int in, int out)
 {
        uint32_t stored_crc = 0;
        unsigned int count;
+       USE_DESKTOP(long long total = )inflate_unzip(in, out);
 
-       inflate_unzip(in, out);
+       USE_DESKTOP(if (total < 0) return total;)
 
        /* top up the input buffer with the rest of the trailer */
        count = bytebuffer_size - bytebuffer_offset;
@@ -915,5 +920,5 @@ int inflate_gunzip(int in, int out)
                return -1;
        }
 
-       return 0;
+       return USE_DESKTOP(total) + 0;
 }