aboutsummaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
Diffstat (limited to 'archival')
-rw-r--r--archival/unzip.c57
1 files changed, 37 insertions, 20 deletions
diff --git a/archival/unzip.c b/archival/unzip.c
index a9b7dc10f..473cbe2ec 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -156,15 +156,15 @@ typedef union {
156#define FIX_ENDIANNESS_CDF(cdf) \ 156#define FIX_ENDIANNESS_CDF(cdf) \
157do { if (BB_BIG_ENDIAN) { \ 157do { if (BB_BIG_ENDIAN) { \
158 (cdf).fmt.version_made_by = SWAP_LE16((cdf).fmt.version_made_by); \ 158 (cdf).fmt.version_made_by = SWAP_LE16((cdf).fmt.version_made_by); \
159 (cdf).fmt.version_needed = SWAP_LE16((cdf).fmt.version_needed); \ 159 (cdf).fmt.version_needed = SWAP_LE16((cdf).fmt.version_needed ); \
160 (cdf).fmt.method = SWAP_LE16((cdf).fmt.method ); \ 160 (cdf).fmt.method = SWAP_LE16((cdf).fmt.method ); \
161 (cdf).fmt.modtime = SWAP_LE16((cdf).fmt.modtime ); \ 161 (cdf).fmt.modtime = SWAP_LE16((cdf).fmt.modtime ); \
162 (cdf).fmt.moddate = SWAP_LE16((cdf).fmt.moddate ); \ 162 (cdf).fmt.moddate = SWAP_LE16((cdf).fmt.moddate ); \
163 (cdf).fmt.crc32 = SWAP_LE32((cdf).fmt.crc32 ); \ 163 (cdf).fmt.crc32 = SWAP_LE32((cdf).fmt.crc32 ); \
164 (cdf).fmt.cmpsize = SWAP_LE32((cdf).fmt.cmpsize ); \ 164 (cdf).fmt.cmpsize = SWAP_LE32((cdf).fmt.cmpsize ); \
165 (cdf).fmt.ucmpsize = SWAP_LE32((cdf).fmt.ucmpsize ); \ 165 (cdf).fmt.ucmpsize = SWAP_LE32((cdf).fmt.ucmpsize ); \
166 (cdf).fmt.filename_len = SWAP_LE16((cdf).fmt.filename_len); \ 166 (cdf).fmt.filename_len = SWAP_LE16((cdf).fmt.filename_len ); \
167 (cdf).fmt.extra_len = SWAP_LE16((cdf).fmt.extra_len ); \ 167 (cdf).fmt.extra_len = SWAP_LE16((cdf).fmt.extra_len ); \
168 (cdf).fmt.file_comment_length = SWAP_LE16((cdf).fmt.file_comment_length); \ 168 (cdf).fmt.file_comment_length = SWAP_LE16((cdf).fmt.file_comment_length); \
169 (cdf).fmt.external_attributes = SWAP_LE32((cdf).fmt.external_attributes); \ 169 (cdf).fmt.external_attributes = SWAP_LE32((cdf).fmt.external_attributes); \
170}} while (0) 170}} while (0)
@@ -459,7 +459,9 @@ static int get_lstat_mode(const char *dst_fn)
459 struct stat stat_buf; 459 struct stat stat_buf;
460 if (lstat(dst_fn, &stat_buf) == -1) { 460 if (lstat(dst_fn, &stat_buf) == -1) {
461 if (errno != ENOENT) { 461 if (errno != ENOENT) {
462 bb_perror_msg_and_die("can't stat '%s'", dst_fn); 462 bb_perror_msg_and_die("can't stat '%s'",
463 dst_fn
464 );
463 } 465 }
464 /* File does not exist */ 466 /* File does not exist */
465 return -1; 467 return -1;
@@ -637,7 +639,9 @@ int unzip_main(int argc, char **argv)
637 break; 639 break;
638 if (++i > 2) { 640 if (++i > 2) {
639 *ext = '\0'; 641 *ext = '\0';
640 bb_error_msg_and_die("can't open %s[.zip]", src_fn); 642 bb_error_msg_and_die("can't open %s[.zip]",
643 src_fn
644 );
641 } 645 }
642 strcpy(ext, extn[i - 1]); 646 strcpy(ext, extn[i - 1]);
643 } 647 }
@@ -649,8 +653,11 @@ int unzip_main(int argc, char **argv)
649 xchdir(base_dir); 653 xchdir(base_dir);
650 654
651 if (quiet <= 1) { /* not -qq */ 655 if (quiet <= 1) { /* not -qq */
652 if (quiet == 0) 656 if (quiet == 0) {
653 printf("Archive: %s\n", src_fn); 657 printf("Archive: %s\n",
658 printable_string(src_fn)
659 );
660 }
654 if (opts & OPT_l) { 661 if (opts & OPT_l) {
655 puts(verbose ? 662 puts(verbose ?
656 " Length Method Size Cmpr Date Time CRC-32 Name\n" 663 " Length Method Size Cmpr Date Time CRC-32 Name\n"
@@ -834,7 +841,8 @@ int unzip_main(int argc, char **argv)
834 printf( "%9u " "%s " "%s\n", 841 printf( "%9u " "%s " "%s\n",
835 (unsigned)zip.fmt.ucmpsize, 842 (unsigned)zip.fmt.ucmpsize,
836 dtbuf, 843 dtbuf,
837 dst_fn); 844 printable_string(dst_fn)
845 );
838 } else { 846 } else {
839 char method6[7]; 847 char method6[7];
840 unsigned long percents; 848 unsigned long percents;
@@ -863,7 +871,8 @@ int unzip_main(int argc, char **argv)
863 (unsigned)percents, 871 (unsigned)percents,
864 dtbuf, 872 dtbuf,
865 zip.fmt.crc32, 873 zip.fmt.crc32,
866 dst_fn); 874 printable_string(dst_fn)
875 );
867 total_size += zip.fmt.cmpsize; 876 total_size += zip.fmt.cmpsize;
868 } 877 }
869 total_usize += zip.fmt.ucmpsize; 878 total_usize += zip.fmt.ucmpsize;
@@ -889,7 +898,7 @@ int unzip_main(int argc, char **argv)
889 mode = get_lstat_mode(dst_fn); 898 mode = get_lstat_mode(dst_fn);
890 if (mode == -1) { /* ENOENT */ 899 if (mode == -1) { /* ENOENT */
891 if (!quiet) { 900 if (!quiet) {
892 printf(" creating: %s\n", dst_fn); 901 printf(" creating: %s\n", printable_string(dst_fn));
893 } 902 }
894 unzip_create_leading_dirs(dst_fn); 903 unzip_create_leading_dirs(dst_fn);
895 if (bb_make_directory(dst_fn, dir_mode, FILEUTILS_IGNORE_CHMOD_ERR)) { 904 if (bb_make_directory(dst_fn, dir_mode, FILEUTILS_IGNORE_CHMOD_ERR)) {
@@ -898,7 +907,9 @@ int unzip_main(int argc, char **argv)
898 } else { 907 } else {
899 if (!S_ISDIR(mode)) { 908 if (!S_ISDIR(mode)) {
900 bb_error_msg_and_die("'%s' exists but is not a %s", 909 bb_error_msg_and_die("'%s' exists but is not a %s",
901 dst_fn, "directory"); 910 printable_string(dst_fn),
911 "directory"
912 );
902 } 913 }
903 } 914 }
904 goto skip_cmpsize; 915 goto skip_cmpsize;
@@ -917,12 +928,16 @@ int unzip_main(int argc, char **argv)
917 if (!S_ISREG(mode)) { 928 if (!S_ISREG(mode)) {
918 fishy: 929 fishy:
919 bb_error_msg_and_die("'%s' exists but is not a %s", 930 bb_error_msg_and_die("'%s' exists but is not a %s",
920 dst_fn, "regular file"); 931 printable_string(dst_fn),
932 "regular file"
933 );
921 } 934 }
922 if (overwrite == O_ALWAYS) { 935 if (overwrite == O_ALWAYS) {
923 goto do_open_and_extract; 936 goto do_open_and_extract;
924 } 937 }
925 printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn); 938 printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ",
939 printable_string(dst_fn)
940 );
926 my_fgets80(key_buf); 941 my_fgets80(key_buf);
927 /* User input could take a long time. Is it still a regular file? */ 942 /* User input could take a long time. Is it still a regular file? */
928 mode = get_lstat_mode(dst_fn); 943 mode = get_lstat_mode(dst_fn);
@@ -952,7 +967,9 @@ int unzip_main(int argc, char **argv)
952 if (!quiet) { 967 if (!quiet) {
953 printf(/* zip.fmt.method == 0 968 printf(/* zip.fmt.method == 0
954 ? " extracting: %s\n" 969 ? " extracting: %s\n"
955 : */ " inflating: %s\n", dst_fn); 970 : */ " inflating: %s\n",
971 printable_string(dst_fn)
972 );
956 } 973 }
957#if ENABLE_FEATURE_UNZIP_CDF 974#if ENABLE_FEATURE_UNZIP_CDF
958 if (S_ISLNK(file_mode)) { 975 if (S_ISLNK(file_mode)) {