diff options
Diffstat (limited to 'busybox/archival')
-rw-r--r-- | busybox/archival/ar.c | 11 | ||||
-rw-r--r-- | busybox/archival/dpkg.c | 2 | ||||
-rw-r--r-- | busybox/archival/dpkg_deb.c | 2 | ||||
-rw-r--r-- | busybox/archival/gzip.c | 47 | ||||
-rw-r--r-- | busybox/archival/libunarchive/archive_xread_all_eof.c | 2 | ||||
-rw-r--r-- | busybox/archival/libunarchive/decompress_bunzip2.c | 25 | ||||
-rw-r--r-- | busybox/archival/libunarchive/decompress_unzip.c | 5 | ||||
-rw-r--r-- | busybox/archival/tar.c | 2 |
8 files changed, 43 insertions, 53 deletions
diff --git a/busybox/archival/ar.c b/busybox/archival/ar.c index 44c5db0..8326aa6 100644 --- a/busybox/archival/ar.c +++ b/busybox/archival/ar.c @@ -56,19 +56,21 @@ static void header_verbose_list_ar(const file_header_t *file_header) #define AR_OPT_PRESERVE_DATE 0x08 #define AR_OPT_VERBOSE 0x10 #define AR_OPT_CREATE 0x20 +#define AR_OPT_INSERT 0x40 extern int ar_main(int argc, char **argv) { archive_handle_t *archive_handle; unsigned long opt; + char *msg_unsupported_err = "Archive %s not supported. Install binutils 'ar'."; char magic[8]; archive_handle = init_handle(); bb_opt_complementaly = "p~tx:t~px:x~pt"; - opt = bb_getopt_ulflags(argc, argv, "ptxovc"); + opt = bb_getopt_ulflags(argc, argv, "ptxovcr"); - if ((opt & 0x80000000UL) || (optind == argc)) { + if ((opt & BB_GETOPT_ERROR) || (opt == 0) || (optind == argc)) { bb_show_usage(); } @@ -88,7 +90,10 @@ extern int ar_main(int argc, char **argv) archive_handle->action_header = header_verbose_list_ar; } if (opt & AR_OPT_CREATE) { - bb_error_msg_and_die("Archive creation not supported. Install binutils 'ar'."); + bb_error_msg_and_die(msg_unsupported_err, "creation"); + } + if (opt & AR_OPT_INSERT) { + bb_error_msg_and_die(msg_unsupported_err, "insertion"); } archive_handle->src_fd = bb_xopen(argv[optind++], O_RDONLY); diff --git a/busybox/archival/dpkg.c b/busybox/archival/dpkg.c index c096518..d3b56e3 100644 --- a/busybox/archival/dpkg.c +++ b/busybox/archival/dpkg.c @@ -1327,7 +1327,7 @@ void free_array(char **array) * the status_hashtable to retrieve the info. This results in smaller code than * scanning the status file. The resulting list, however, is unsorted. */ -void list_packages(void) +static void list_packages(void) { int i; diff --git a/busybox/archival/dpkg_deb.c b/busybox/archival/dpkg_deb.c index 5aa9881..b95ec2d 100644 --- a/busybox/archival/dpkg_deb.c +++ b/busybox/archival/dpkg_deb.c @@ -88,7 +88,7 @@ extern int dpkg_deb_main(int argc, char **argv) argcount = 2; } - if ((optind + argcount != argc) || (opt & 0x80000000UL)) { + if ((optind + argcount != argc) || (opt & BB_GETOPT_ERROR)) { bb_show_usage(); } diff --git a/busybox/archival/gzip.c b/busybox/archival/gzip.c index d494aa3..6cf4b39 100644 --- a/busybox/archival/gzip.c +++ b/busybox/archival/gzip.c @@ -51,12 +51,6 @@ #include <time.h> #include "busybox.h" -#define memzero(s, n) memset ((void *)(s), 0, (n)) - -#ifndef RETSIGTYPE -# define RETSIGTYPE void -#endif - typedef unsigned char uch; typedef unsigned short ush; typedef unsigned long ulg; @@ -214,9 +208,6 @@ typedef int file_t; /* Do not use stdio */ static int zip(int in, int out); static int file_read(char *buf, unsigned size); - /* from gzip.c */ -static RETSIGTYPE abort_gzip(void); - /* from deflate.c */ static void lm_init(ush * flags); static ulg deflate(void); @@ -335,7 +326,7 @@ static void put_short(ush w) /* ======================================================================== * Signal and error handler. */ -static void abort_gzip() +static void abort_gzip(int ignored) { exit(ERROR); } @@ -350,13 +341,6 @@ static void clear_bufs(void) bytes_in = 0L; } -static void write_bb_error_msg(void) -{ - fputc('\n', stderr); - bb_perror_nomsg(); - abort_gzip(); -} - /* =========================================================================== * Does the same as write(), but also handles partial pipe writes and checks * for error return. @@ -366,9 +350,7 @@ static void write_buf(int fd, void *buf, unsigned cnt) unsigned n; while ((n = write(fd, buf, cnt)) != cnt) { - if (n == (unsigned) (-1)) { - write_bb_error_msg(); - } + if (n == (unsigned) (-1)) bb_error_msg_and_die("can't write"); cnt -= n; buf = (void *) ((char *) buf + n); } @@ -559,7 +541,7 @@ static unsigned bi_reverse(unsigned code, int len) /* =========================================================================== * Write out any remaining bits in an incomplete byte. */ -static void bi_windup() +static void bi_windup(void) { if (bi_valid > 8) { put_short(bi_buf); @@ -846,7 +828,7 @@ static void lm_init(ush * flags) register unsigned j; /* Initialize the hash table. */ - memzero((char *) head, HASH_SIZE * sizeof(*head)); + memset(head, 0, HASH_SIZE * sizeof(*head)); /* prev will be initialized on the fly */ *flags |= SLOW; @@ -996,7 +978,7 @@ static void check_match(IPos start, IPos match, int length) * file reads are performed for at least two bytes (required for the * translate_eol option). */ -static void fill_window() +static void fill_window(void) { register unsigned n, m; unsigned more = @@ -1060,7 +1042,7 @@ static void fill_window() * evaluation for matches: a match is finally adopted only if there is * no better match at the next window position. */ -static ulg deflate() +static ulg deflate(void) { IPos hash_head; /* head of hash chain */ IPos prev_match; /* previous match */ @@ -1188,8 +1170,6 @@ static ulg deflate() typedef struct dirent dir_type; -typedef RETSIGTYPE(*sig_type) (int); - /* ======================================================================== */ int gzip_main(int argc, char **argv) { @@ -1235,16 +1215,16 @@ int gzip_main(int argc, char **argv) foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; if (foreground) { - (void) signal(SIGINT, (sig_type) abort_gzip); + (void) signal(SIGINT, abort_gzip); } #ifdef SIGTERM if (signal(SIGTERM, SIG_IGN) != SIG_IGN) { - (void) signal(SIGTERM, (sig_type) abort_gzip); + (void) signal(SIGTERM, abort_gzip); } #endif #ifdef SIGHUP if (signal(SIGHUP, SIG_IGN) != SIG_IGN) { - (void) signal(SIGHUP, (sig_type) abort_gzip); + (void) signal(SIGHUP, abort_gzip); } #endif @@ -1271,6 +1251,7 @@ int gzip_main(int argc, char **argv) for (i = optind; i < argc; i++) { char *path = NULL; + clear_bufs(); if (strcmp(argv[i], "-") == 0) { time_stamp = 0; ifile_size = -1L; @@ -1749,7 +1730,7 @@ static void ct_init(ush * attr, int *methodp) /* =========================================================================== * Initialize a new block. */ -static void init_block() +static void init_block(void) { int n; /* iterates over tree elements */ @@ -2162,7 +2143,7 @@ static void send_tree(ct_data * tree, int max_code) * Construct the Huffman tree for the bit lengths and return the index in * bl_order of the last bit length code to send. */ -static const int build_bl_tree() +static int build_bl_tree(void) { int max_blindex; /* index of last bit length code of non zero freq */ @@ -2425,7 +2406,7 @@ static void compress_block(ct_data * ltree, ct_data * dtree) * IN assertion: the fields freq of dyn_ltree are set and the total of all * frequencies does not exceed 64K (to fit in an int on 16 bit machines). */ -static void set_file_type() +static void set_file_type(void) { int n = 0; unsigned ascii_freq = 0; @@ -2538,7 +2519,7 @@ static int file_read(char *buf, unsigned size) * Write the output buffer outbuf[0..outcnt-1] and update bytes_out. * (used for the compressed data only) */ -static void flush_outbuf() +static void flush_outbuf(void) { if (outcnt == 0) return; diff --git a/busybox/archival/libunarchive/archive_xread_all_eof.c b/busybox/archival/libunarchive/archive_xread_all_eof.c index 8084e35..f1eea29 100644 --- a/busybox/archival/libunarchive/archive_xread_all_eof.c +++ b/busybox/archival/libunarchive/archive_xread_all_eof.c @@ -26,7 +26,7 @@ extern ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, unsigned size = bb_full_read(archive_handle->src_fd, buf, count); if ((size != 0) && (size != count)) { - bb_perror_msg_and_die("Short read, read %d of %d", size, count); + bb_perror_msg_and_die("Short read, read %ld of %ld", (long)size, (long)count); } return(size); } diff --git a/busybox/archival/libunarchive/decompress_bunzip2.c b/busybox/archival/libunarchive/decompress_bunzip2.c index 259a477..07e3cf0 100644 --- a/busybox/archival/libunarchive/decompress_bunzip2.c +++ b/busybox/archival/libunarchive/decompress_bunzip2.c @@ -134,8 +134,6 @@ static unsigned int get_bits(bunzip_data *bd, char bits_wanted) static int get_next_block(bunzip_data *bd) { - /* Note: Ignore the warning about hufGroup, base and limit being used uninitialized. - * They will be initialized on the fist pass of the loop. */ struct group_data *hufGroup; int dbufCount,nextSym,dbufSize,groupCount,*base,*limit,selector, i,j,k,t,runPos,symCount,symTotal,nSelectors,byteCount[256]; @@ -286,16 +284,15 @@ static int get_next_block(bunzip_data *bd) mtfSymbol[i]=(unsigned char)i; } /* Loop through compressed symbols. */ - runPos=dbufCount=symCount=selector=0; + runPos=dbufCount=selector=0; for(;;) { - /* Determine which Huffman coding group to use. */ - if(!(symCount--)) { - symCount=GROUP_SIZE-1; - if(selector>=nSelectors) return RETVAL_DATA_ERROR; - hufGroup=bd->groups+selectors[selector++]; - base=hufGroup->base-1; - limit=hufGroup->limit-1; - } + /* fetch next Huffman coding group from list. */ + symCount=GROUP_SIZE-1; + if(selector>=nSelectors) return RETVAL_DATA_ERROR; + hufGroup=bd->groups+selectors[selector++]; + base=hufGroup->base-1; + limit=hufGroup->limit-1; +continue_this_group: /* Read next Huffman-coded symbol. */ /* Note: It is far cheaper to read maxLen bits and back up than it is to read minLen bits and then an additional bit at a time, testing @@ -346,7 +343,7 @@ got_huff_bits: context). Thus space is saved. */ t += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */ runPos <<= 1; - continue; + goto end_of_huffman_loop; } /* When we hit the first non-run symbol after a run, we now know how many times to repeat the last literal, so append that many @@ -384,6 +381,10 @@ got_huff_bits: /* We have our literal byte. Save it into dbuf. */ byteCount[uc]++; dbuf[dbufCount++] = (unsigned int)uc; + /* Skip group initialization if we're not done with this group. Done this + * way to avoid compiler warning. */ +end_of_huffman_loop: + if(symCount--) goto continue_this_group; } /* At this point, we've read all the Huffman-coded symbols (and repeated runs) for this block from the input stream, and decoded them into the diff --git a/busybox/archival/libunarchive/decompress_unzip.c b/busybox/archival/libunarchive/decompress_unzip.c index e8cf54b..b17065d 100644 --- a/busybox/archival/libunarchive/decompress_unzip.c +++ b/busybox/archival/libunarchive/decompress_unzip.c @@ -151,7 +151,10 @@ static unsigned int fill_bitbuffer(unsigned int bitbuffer, unsigned int *current /* Leave the first 4 bytes empty so we can always unwind the bitbuffer * to the front of the bytebuffer, leave 4 bytes free at end of tail * so we can easily top up buffer in check_trailer_gzip() */ - bytebuffer_size = 4 + bb_xread(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 8); + if (!(bytebuffer_size = bb_xread(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 8))) { + bb_error_msg_and_die("unexpected end of file"); + } + bytebuffer_size += 4; bytebuffer_offset = 4; } bitbuffer |= ((unsigned int) bytebuffer[bytebuffer_offset]) << *current; diff --git a/busybox/archival/tar.c b/busybox/archival/tar.c index 950e21d..b2a2123 100644 --- a/busybox/archival/tar.c +++ b/busybox/archival/tar.c @@ -724,7 +724,7 @@ int tar_main(int argc, char **argv) ); /* Check one and only one context option was given */ - if(opt & 0x80000000UL) { + if(opt & BB_GETOPT_ERROR) { bb_show_usage(); } #ifdef CONFIG_FEATURE_TAR_CREATE |