diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-09-30 16:56:56 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-09-30 16:56:56 +0200 |
commit | 349d72c19ced4fae64e8fdd5792b37e78ac2f616 (patch) | |
tree | c7f228ac570984a552242e64fe815d212876c0dc /archival/unzip.c | |
parent | 14454b3071c7a5c053fde8eed416ab3b2f8475fb (diff) | |
download | busybox-w32-349d72c19ced4fae64e8fdd5792b37e78ac2f616.tar.gz busybox-w32-349d72c19ced4fae64e8fdd5792b37e78ac2f616.tar.bz2 busybox-w32-349d72c19ced4fae64e8fdd5792b37e78ac2f616.zip |
unzip: use printable_string() for printing filenames
function old new delta
unzip_main 2726 2792 +66
printable_string2 - 57 +57
identify 4329 4336 +7
expmeta 659 663 +4
add_interface 99 103 +4
beep_main 286 289 +3
changepath 192 194 +2
builtin_type 115 117 +2
devmem_main 469 470 +1
input_tab 1076 1074 -2
create_J 1821 1819 -2
poplocalvars 314 311 -3
doCommands 2222 2214 -8
do_load 918 902 -16
printable_string 57 9 -48
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 8/6 up/down: 146/-79) Total: 67 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/unzip.c')
-rw-r--r-- | archival/unzip.c | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/archival/unzip.c b/archival/unzip.c index 96b7ab69b..c406d53c4 100644 --- a/archival/unzip.c +++ b/archival/unzip.c | |||
@@ -153,15 +153,15 @@ typedef union { | |||
153 | #define FIX_ENDIANNESS_CDF(cdf) \ | 153 | #define FIX_ENDIANNESS_CDF(cdf) \ |
154 | do { if (BB_BIG_ENDIAN) { \ | 154 | do { if (BB_BIG_ENDIAN) { \ |
155 | (cdf).fmt.version_made_by = SWAP_LE16((cdf).fmt.version_made_by); \ | 155 | (cdf).fmt.version_made_by = SWAP_LE16((cdf).fmt.version_made_by); \ |
156 | (cdf).fmt.version_needed = SWAP_LE16((cdf).fmt.version_needed); \ | 156 | (cdf).fmt.version_needed = SWAP_LE16((cdf).fmt.version_needed ); \ |
157 | (cdf).fmt.method = SWAP_LE16((cdf).fmt.method ); \ | 157 | (cdf).fmt.method = SWAP_LE16((cdf).fmt.method ); \ |
158 | (cdf).fmt.modtime = SWAP_LE16((cdf).fmt.modtime ); \ | 158 | (cdf).fmt.modtime = SWAP_LE16((cdf).fmt.modtime ); \ |
159 | (cdf).fmt.moddate = SWAP_LE16((cdf).fmt.moddate ); \ | 159 | (cdf).fmt.moddate = SWAP_LE16((cdf).fmt.moddate ); \ |
160 | (cdf).fmt.crc32 = SWAP_LE32((cdf).fmt.crc32 ); \ | 160 | (cdf).fmt.crc32 = SWAP_LE32((cdf).fmt.crc32 ); \ |
161 | (cdf).fmt.cmpsize = SWAP_LE32((cdf).fmt.cmpsize ); \ | 161 | (cdf).fmt.cmpsize = SWAP_LE32((cdf).fmt.cmpsize ); \ |
162 | (cdf).fmt.ucmpsize = SWAP_LE32((cdf).fmt.ucmpsize ); \ | 162 | (cdf).fmt.ucmpsize = SWAP_LE32((cdf).fmt.ucmpsize ); \ |
163 | (cdf).fmt.filename_len = SWAP_LE16((cdf).fmt.filename_len); \ | 163 | (cdf).fmt.filename_len = SWAP_LE16((cdf).fmt.filename_len ); \ |
164 | (cdf).fmt.extra_len = SWAP_LE16((cdf).fmt.extra_len ); \ | 164 | (cdf).fmt.extra_len = SWAP_LE16((cdf).fmt.extra_len ); \ |
165 | (cdf).fmt.file_comment_length = SWAP_LE16((cdf).fmt.file_comment_length); \ | 165 | (cdf).fmt.file_comment_length = SWAP_LE16((cdf).fmt.file_comment_length); \ |
166 | (cdf).fmt.external_attributes = SWAP_LE32((cdf).fmt.external_attributes); \ | 166 | (cdf).fmt.external_attributes = SWAP_LE32((cdf).fmt.external_attributes); \ |
167 | }} while (0) | 167 | }} while (0) |
@@ -456,7 +456,9 @@ static int get_lstat_mode(const char *dst_fn) | |||
456 | struct stat stat_buf; | 456 | struct stat stat_buf; |
457 | if (lstat(dst_fn, &stat_buf) == -1) { | 457 | if (lstat(dst_fn, &stat_buf) == -1) { |
458 | if (errno != ENOENT) { | 458 | if (errno != ENOENT) { |
459 | bb_perror_msg_and_die("can't stat '%s'", dst_fn); | 459 | bb_perror_msg_and_die("can't stat '%s'", |
460 | dst_fn | ||
461 | ); | ||
460 | } | 462 | } |
461 | /* File does not exist */ | 463 | /* File does not exist */ |
462 | return -1; | 464 | return -1; |
@@ -634,7 +636,9 @@ int unzip_main(int argc, char **argv) | |||
634 | break; | 636 | break; |
635 | if (++i > 2) { | 637 | if (++i > 2) { |
636 | *ext = '\0'; | 638 | *ext = '\0'; |
637 | bb_error_msg_and_die("can't open %s[.zip]", src_fn); | 639 | bb_error_msg_and_die("can't open %s[.zip]", |
640 | src_fn | ||
641 | ); | ||
638 | } | 642 | } |
639 | strcpy(ext, extn[i - 1]); | 643 | strcpy(ext, extn[i - 1]); |
640 | } | 644 | } |
@@ -646,8 +650,11 @@ int unzip_main(int argc, char **argv) | |||
646 | xchdir(base_dir); | 650 | xchdir(base_dir); |
647 | 651 | ||
648 | if (quiet <= 1) { /* not -qq */ | 652 | if (quiet <= 1) { /* not -qq */ |
649 | if (quiet == 0) | 653 | if (quiet == 0) { |
650 | printf("Archive: %s\n", src_fn); | 654 | printf("Archive: %s\n", |
655 | printable_string(src_fn) | ||
656 | ); | ||
657 | } | ||
651 | if (opts & OPT_l) { | 658 | if (opts & OPT_l) { |
652 | puts(verbose ? | 659 | puts(verbose ? |
653 | " Length Method Size Cmpr Date Time CRC-32 Name\n" | 660 | " Length Method Size Cmpr Date Time CRC-32 Name\n" |
@@ -831,7 +838,8 @@ int unzip_main(int argc, char **argv) | |||
831 | printf( "%9u " "%s " "%s\n", | 838 | printf( "%9u " "%s " "%s\n", |
832 | (unsigned)zip.fmt.ucmpsize, | 839 | (unsigned)zip.fmt.ucmpsize, |
833 | dtbuf, | 840 | dtbuf, |
834 | dst_fn); | 841 | printable_string(dst_fn) |
842 | ); | ||
835 | } else { | 843 | } else { |
836 | char method6[7]; | 844 | char method6[7]; |
837 | unsigned long percents; | 845 | unsigned long percents; |
@@ -860,7 +868,8 @@ int unzip_main(int argc, char **argv) | |||
860 | (unsigned)percents, | 868 | (unsigned)percents, |
861 | dtbuf, | 869 | dtbuf, |
862 | zip.fmt.crc32, | 870 | zip.fmt.crc32, |
863 | dst_fn); | 871 | printable_string(dst_fn) |
872 | ); | ||
864 | total_size += zip.fmt.cmpsize; | 873 | total_size += zip.fmt.cmpsize; |
865 | } | 874 | } |
866 | total_usize += zip.fmt.ucmpsize; | 875 | total_usize += zip.fmt.ucmpsize; |
@@ -886,7 +895,7 @@ int unzip_main(int argc, char **argv) | |||
886 | mode = get_lstat_mode(dst_fn); | 895 | mode = get_lstat_mode(dst_fn); |
887 | if (mode == -1) { /* ENOENT */ | 896 | if (mode == -1) { /* ENOENT */ |
888 | if (!quiet) { | 897 | if (!quiet) { |
889 | printf(" creating: %s\n", dst_fn); | 898 | printf(" creating: %s\n", printable_string(dst_fn)); |
890 | } | 899 | } |
891 | unzip_create_leading_dirs(dst_fn); | 900 | unzip_create_leading_dirs(dst_fn); |
892 | if (bb_make_directory(dst_fn, dir_mode, FILEUTILS_IGNORE_CHMOD_ERR)) { | 901 | if (bb_make_directory(dst_fn, dir_mode, FILEUTILS_IGNORE_CHMOD_ERR)) { |
@@ -895,7 +904,9 @@ int unzip_main(int argc, char **argv) | |||
895 | } else { | 904 | } else { |
896 | if (!S_ISDIR(mode)) { | 905 | if (!S_ISDIR(mode)) { |
897 | bb_error_msg_and_die("'%s' exists but is not a %s", | 906 | bb_error_msg_and_die("'%s' exists but is not a %s", |
898 | dst_fn, "directory"); | 907 | printable_string(dst_fn), |
908 | "directory" | ||
909 | ); | ||
899 | } | 910 | } |
900 | } | 911 | } |
901 | goto skip_cmpsize; | 912 | goto skip_cmpsize; |
@@ -914,12 +925,16 @@ int unzip_main(int argc, char **argv) | |||
914 | if (!S_ISREG(mode)) { | 925 | if (!S_ISREG(mode)) { |
915 | fishy: | 926 | fishy: |
916 | bb_error_msg_and_die("'%s' exists but is not a %s", | 927 | bb_error_msg_and_die("'%s' exists but is not a %s", |
917 | dst_fn, "regular file"); | 928 | printable_string(dst_fn), |
929 | "regular file" | ||
930 | ); | ||
918 | } | 931 | } |
919 | if (overwrite == O_ALWAYS) { | 932 | if (overwrite == O_ALWAYS) { |
920 | goto do_open_and_extract; | 933 | goto do_open_and_extract; |
921 | } | 934 | } |
922 | printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn); | 935 | printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", |
936 | printable_string(dst_fn) | ||
937 | ); | ||
923 | my_fgets80(key_buf); | 938 | my_fgets80(key_buf); |
924 | /* User input could take a long time. Is it still a regular file? */ | 939 | /* User input could take a long time. Is it still a regular file? */ |
925 | mode = get_lstat_mode(dst_fn); | 940 | mode = get_lstat_mode(dst_fn); |
@@ -949,7 +964,9 @@ int unzip_main(int argc, char **argv) | |||
949 | if (!quiet) { | 964 | if (!quiet) { |
950 | printf(/* zip.fmt.method == 0 | 965 | printf(/* zip.fmt.method == 0 |
951 | ? " extracting: %s\n" | 966 | ? " extracting: %s\n" |
952 | : */ " inflating: %s\n", dst_fn); | 967 | : */ " inflating: %s\n", |
968 | printable_string(dst_fn) | ||
969 | ); | ||
953 | } | 970 | } |
954 | #if ENABLE_FEATURE_UNZIP_CDF | 971 | #if ENABLE_FEATURE_UNZIP_CDF |
955 | if (S_ISLNK(file_mode)) { | 972 | if (S_ISLNK(file_mode)) { |