diff options
Diffstat (limited to 'archival/libunarchive/unzip.c')
-rw-r--r-- | archival/libunarchive/unzip.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/archival/libunarchive/unzip.c b/archival/libunarchive/unzip.c index 29929c282..a436db191 100644 --- a/archival/libunarchive/unzip.c +++ b/archival/libunarchive/unzip.c | |||
@@ -13,7 +13,7 @@ | |||
13 | * | 13 | * |
14 | * General cleanup to better adhere to the style guide and make use of standard | 14 | * General cleanup to better adhere to the style guide and make use of standard |
15 | * busybox functions by Glenn McGrath <bug1@optushome.com.au> | 15 | * busybox functions by Glenn McGrath <bug1@optushome.com.au> |
16 | * | 16 | * |
17 | * read_gz interface + associated hacking by Laurence Anderson | 17 | * read_gz interface + associated hacking by Laurence Anderson |
18 | * | 18 | * |
19 | * This program is free software; you can redistribute it and/or modify | 19 | * This program is free software; you can redistribute it and/or modify |
@@ -148,7 +148,7 @@ static unsigned int fill_bitbuffer(unsigned int bitbuffer, unsigned int *current | |||
148 | { | 148 | { |
149 | while (*current < required) { | 149 | while (*current < required) { |
150 | if (bytebuffer_offset >= bytebuffer_size) { | 150 | if (bytebuffer_offset >= bytebuffer_size) { |
151 | /* Leave the first 4 bytes empty so we can always unwind the bitbuffer | 151 | /* Leave the first 4 bytes empty so we can always unwind the bitbuffer |
152 | * to the front of the bytebuffer, leave 4 bytes free at end of tail | 152 | * to the front of the bytebuffer, leave 4 bytes free at end of tail |
153 | * so we can easily top up buffer in check_trailer_gzip() */ | 153 | * so we can easily top up buffer in check_trailer_gzip() */ |
154 | bytebuffer_size = 4 + bb_xread(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 8); | 154 | bytebuffer_size = 4 + bb_xread(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 8); |
@@ -193,7 +193,7 @@ static void make_gunzip_crc_table(void) | |||
193 | /* | 193 | /* |
194 | * Free the malloc'ed tables built by huft_build(), which makes a linked | 194 | * Free the malloc'ed tables built by huft_build(), which makes a linked |
195 | * list of the tables it made, with the links in a dummy first entry of | 195 | * list of the tables it made, with the links in a dummy first entry of |
196 | * each table. | 196 | * each table. |
197 | * t: table to free | 197 | * t: table to free |
198 | */ | 198 | */ |
199 | static int huft_free(huft_t * t) | 199 | static int huft_free(huft_t * t) |
@@ -435,9 +435,9 @@ static int inflate_codes(huft_t * my_tl, huft_t * my_td, const unsigned int my_b | |||
435 | md = mask_bits[bd]; | 435 | md = mask_bits[bd]; |
436 | return 0; // Don't actually do anything the first time | 436 | return 0; // Don't actually do anything the first time |
437 | } | 437 | } |
438 | 438 | ||
439 | if (resumeCopy) goto do_copy; | 439 | if (resumeCopy) goto do_copy; |
440 | 440 | ||
441 | while (1) { /* do until end of block */ | 441 | while (1) { /* do until end of block */ |
442 | b = fill_bitbuffer(b, &k, bl); | 442 | b = fill_bitbuffer(b, &k, bl); |
443 | if ((e = (t = tl + ((unsigned) b & ml))->e) > 16) | 443 | if ((e = (t = tl + ((unsigned) b & ml))->e) > 16) |
@@ -533,7 +533,7 @@ do_copy: do { | |||
533 | /* free the decoding tables, return */ | 533 | /* free the decoding tables, return */ |
534 | huft_free(tl); | 534 | huft_free(tl); |
535 | huft_free(td); | 535 | huft_free(td); |
536 | 536 | ||
537 | /* done */ | 537 | /* done */ |
538 | return 0; | 538 | return 0; |
539 | } | 539 | } |
@@ -548,7 +548,7 @@ static int inflate_stored(int my_n, int my_b_stored, int my_k_stored, int setup) | |||
548 | w = gunzip_outbuf_count; /* initialize gunzip_window position */ | 548 | w = gunzip_outbuf_count; /* initialize gunzip_window position */ |
549 | return 0; // Don't do anything first time | 549 | return 0; // Don't do anything first time |
550 | } | 550 | } |
551 | 551 | ||
552 | /* read and output the compressed data */ | 552 | /* read and output the compressed data */ |
553 | while (n--) { | 553 | while (n--) { |
554 | b_stored = fill_bitbuffer(b_stored, &k_stored, 8); | 554 | b_stored = fill_bitbuffer(b_stored, &k_stored, 8); |
@@ -639,7 +639,7 @@ static int inflate_block(int *e) | |||
639 | inflate_stored(n, b_stored, k_stored, 1); // Setup inflate_stored | 639 | inflate_stored(n, b_stored, k_stored, 1); // Setup inflate_stored |
640 | return -1; | 640 | return -1; |
641 | } | 641 | } |
642 | case 1: /* Inflate fixed | 642 | case 1: /* Inflate fixed |
643 | * decompress an inflated type 1 (fixed Huffman codes) block. We should | 643 | * decompress an inflated type 1 (fixed Huffman codes) block. We should |
644 | * either replace this with a custom decoder, or at least precompute the | 644 | * either replace this with a custom decoder, or at least precompute the |
645 | * Huffman tables. | 645 | * Huffman tables. |
@@ -682,9 +682,9 @@ static int inflate_block(int *e) | |||
682 | 682 | ||
683 | /* decompress until an end-of-block code */ | 683 | /* decompress until an end-of-block code */ |
684 | inflate_codes(tl, td, bl, bd, 1); // Setup inflate_codes | 684 | inflate_codes(tl, td, bl, bd, 1); // Setup inflate_codes |
685 | 685 | ||
686 | /* huft_free code moved into inflate_codes */ | 686 | /* huft_free code moved into inflate_codes */ |
687 | 687 | ||
688 | return -2; | 688 | return -2; |
689 | } | 689 | } |
690 | case 2: /* Inflate dynamic */ | 690 | case 2: /* Inflate dynamic */ |
@@ -836,7 +836,7 @@ static int inflate_block(int *e) | |||
836 | inflate_codes(tl, td, bl, bd, 1); // Setup inflate_codes | 836 | inflate_codes(tl, td, bl, bd, 1); // Setup inflate_codes |
837 | 837 | ||
838 | /* huft_free code moved into inflate_codes */ | 838 | /* huft_free code moved into inflate_codes */ |
839 | 839 | ||
840 | return -2; | 840 | return -2; |
841 | } | 841 | } |
842 | default: | 842 | default: |
@@ -859,12 +859,12 @@ static int inflate_get_next_window(void) | |||
859 | static int method = -1; // Method == -1 for stored, -2 for codes | 859 | static int method = -1; // Method == -1 for stored, -2 for codes |
860 | static int e = 0; | 860 | static int e = 0; |
861 | static int needAnotherBlock = 1; | 861 | static int needAnotherBlock = 1; |
862 | 862 | ||
863 | gunzip_outbuf_count = 0; | 863 | gunzip_outbuf_count = 0; |
864 | 864 | ||
865 | while(1) { | 865 | while(1) { |
866 | int ret; | 866 | int ret; |
867 | 867 | ||
868 | if (needAnotherBlock) { | 868 | if (needAnotherBlock) { |
869 | if(e) { | 869 | if(e) { |
870 | calculate_gunzip_crc(); | 870 | calculate_gunzip_crc(); |
@@ -875,7 +875,7 @@ static int inflate_get_next_window(void) | |||
875 | method = inflate_block(&e); | 875 | method = inflate_block(&e); |
876 | needAnotherBlock = 0; | 876 | needAnotherBlock = 0; |
877 | } | 877 | } |
878 | 878 | ||
879 | switch (method) { | 879 | switch (method) { |
880 | case -1: ret = inflate_stored(0,0,0,0); | 880 | case -1: ret = inflate_stored(0,0,0,0); |
881 | break; | 881 | break; |
@@ -920,7 +920,7 @@ extern int inflate_unzip(int in, int out) | |||
920 | make_gunzip_crc_table(); | 920 | make_gunzip_crc_table(); |
921 | 921 | ||
922 | /* Allocate space for buffer */ | 922 | /* Allocate space for buffer */ |
923 | bytebuffer = xmalloc(bytebuffer_max); | 923 | bytebuffer = xmalloc(bytebuffer_max); |
924 | 924 | ||
925 | while(1) { | 925 | while(1) { |
926 | int ret = inflate_get_next_window(); | 926 | int ret = inflate_get_next_window(); |
@@ -977,6 +977,6 @@ extern int inflate_gunzip(int in, int out) | |||
977 | (bytebuffer[bytebuffer_offset+2] << 16) | (bytebuffer[bytebuffer_offset+3] << 24))) { | 977 | (bytebuffer[bytebuffer_offset+2] << 16) | (bytebuffer[bytebuffer_offset+3] << 24))) { |
978 | bb_error_msg("Incorrect length"); | 978 | bb_error_msg("Incorrect length"); |
979 | } | 979 | } |
980 | 980 | ||
981 | return 0; | 981 | return 0; |
982 | } | 982 | } |