X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=archival%2Funzip.c;h=8b1c281c4e0c16582fa6067a280f32dc973d3dc1;hb=3feb2fc535db445951314f57a8f7ecc460b456d9;hp=6dd1d3597edef9c4b46a1ce4b2e1204a6f1f7164;hpb=74bb70cf549ee2a59e716e99f8a6adb0cf4acc9c;p=oweals%2Fbusybox.git diff --git a/archival/unzip.c b/archival/unzip.c index 6dd1d3597..8b1c281c4 100644 --- a/archival/unzip.c +++ b/archival/unzip.c @@ -55,7 +55,7 @@ static void unzip_skip(int fd, off_t skip) { if (lseek(fd, skip, SEEK_CUR) == (off_t)-1) { if ((errno != ESPIPE) || (bb_copyfd_size(fd, -1, skip) != skip)) { - bb_error_msg_and_die("Seek failure"); + bb_error_msg_and_die("seek failure"); } } } @@ -65,7 +65,7 @@ static void unzip_create_leading_dirs(char *fn) /* Create all leading directories */ char *name = xstrdup(fn); if (bb_make_directory(dirname(name), 0777, FILEUTILS_RECUR)) { - bb_error_msg_and_die("Exiting"); /* bb_make_directory is noisy */ + bb_error_msg_and_die("exiting"); /* bb_make_directory is noisy */ } free(name); } @@ -74,9 +74,9 @@ static int unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd) { if (zip_header->formatted.method == 0) { /* Method 0 - stored (not compressed) */ - int size = zip_header->formatted.ucmpsize; + off_t size = zip_header->formatted.ucmpsize; if (size && (bb_copyfd_size(src_fd, dst_fd, size) != size)) { - bb_error_msg_and_die("Cannot complete extraction"); + bb_error_msg_and_die("cannot complete extraction"); } } else { @@ -86,12 +86,12 @@ static int unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd) inflate_cleanup(); /* Validate decompression - crc */ if (zip_header->formatted.crc32 != (gunzip_crc ^ 0xffffffffL)) { - bb_error_msg("Invalid compressed data--crc error"); + bb_error_msg("invalid compressed data--%s error", "crc"); return 1; } /* Validate decompression - size */ if (zip_header->formatted.ucmpsize != gunzip_bytes_out) { - bb_error_msg("Invalid compressed data--length error"); + bb_error_msg("invalid compressed data--%s error", "length"); return 1; } } @@ -115,9 +115,9 @@ int unzip_main(int argc, char **argv) struct stat stat_buf; while((opt = getopt(argc, argv, "-d:lnopqx")) != -1) { - switch(opt_range) { + switch (opt_range) { case 0: /* Options */ - switch(opt) { + switch (opt) { case 'l': /* List */ verbosity = v_list; break; @@ -201,7 +201,7 @@ int unzip_main(int argc, char **argv) } if (src_fd == -1) { src_fn[orig_src_fn_len] = 0; - bb_error_msg_and_die("Cannot open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn); + bb_error_msg_and_die("cannot open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn); } } @@ -222,7 +222,7 @@ int unzip_main(int argc, char **argv) if (magic == ZIP_CDS_MAGIC) { break; } else if (magic != ZIP_FILEHEADER_MAGIC) { - bb_error_msg_and_die("Invalid zip magic %08X", magic); + bb_error_msg_and_die("invalid zip magic %08X", magic); } /* Read the file header */ @@ -238,7 +238,7 @@ int unzip_main(int argc, char **argv) zip_header.formatted.filename_len = SWAP_LE32(zip_header.formatted.filename_len); zip_header.formatted.extra_len = SWAP_LE32(zip_header.formatted.extra_len); if ((zip_header.formatted.method != 0) && (zip_header.formatted.method != 8)) { - bb_error_msg_and_die("Unsupported compression method %d", zip_header.formatted.method); + bb_error_msg_and_die("unsupported compression method %d", zip_header.formatted.method); } /* Read filename */ @@ -251,7 +251,7 @@ int unzip_main(int argc, char **argv) if ((verbosity == v_list) && !list_header_done){ printf(" Length Date Time Name\n" - " -------- ---- ---- ----\n"); + " -------- ---- ---- ----\n"); list_header_done = 1; } @@ -282,14 +282,14 @@ int unzip_main(int argc, char **argv) } else if (last_char_is(dst_fn, '/')) { /* Extract directory */ if (stat(dst_fn, &stat_buf) == -1) { if (errno != ENOENT) { - bb_perror_msg_and_die("Cannot stat '%s'",dst_fn); + bb_perror_msg_and_die("cannot stat '%s'",dst_fn); } if (verbosity == v_normal) { printf(" creating: %s\n", dst_fn); } unzip_create_leading_dirs(dst_fn); if (bb_make_directory(dst_fn, 0777, 0)) { - bb_error_msg_and_die("Exiting"); + bb_error_msg_and_die("exiting"); } } else { if (!S_ISDIR(stat_buf.st_mode)) { @@ -302,7 +302,7 @@ int unzip_main(int argc, char **argv) _check_file: if (stat(dst_fn, &stat_buf) == -1) { /* File does not exist */ if (errno != ENOENT) { - bb_perror_msg_and_die("Cannot stat '%s'",dst_fn); + bb_perror_msg_and_die("cannot stat '%s'",dst_fn); } i = 'y'; @@ -316,7 +316,7 @@ int unzip_main(int argc, char **argv) } else { printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn); if (!fgets(key_buf, 512, stdin)) { - bb_perror_msg_and_die("Cannot read input"); + bb_perror_msg_and_die("cannot read input"); } i = key_buf[0]; } @@ -333,7 +333,7 @@ int unzip_main(int argc, char **argv) overwrite = o_always; case 'y': /* Open file and fall into unzip */ unzip_create_leading_dirs(dst_fn); - dst_fd = xopen3(dst_fn, O_WRONLY | O_CREAT, 0777); + dst_fd = xopen(dst_fn, O_WRONLY | O_CREAT | O_TRUNC); case -1: /* Unzip */ if (verbosity == v_normal) { printf(" inflating: %s\n", dst_fn); @@ -358,7 +358,7 @@ int unzip_main(int argc, char **argv) /* Prompt for new name */ printf("new name: "); if (!fgets(key_buf, 512, stdin)) { - bb_perror_msg_and_die("Cannot read input"); + bb_perror_msg_and_die("cannot read input"); } free(dst_fn); dst_fn = xstrdup(key_buf);