diff options
Diffstat (limited to 'archival')
-rw-r--r-- | archival/cpio.c | 1 | ||||
-rw-r--r-- | archival/unzip.c | 22 |
2 files changed, 19 insertions, 4 deletions
diff --git a/archival/cpio.c b/archival/cpio.c index a642bbc35..388ba7c4f 100644 --- a/archival/cpio.c +++ b/archival/cpio.c | |||
@@ -508,7 +508,6 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
508 | goto dump; | 508 | goto dump; |
509 | } | 509 | } |
510 | /* parent */ | 510 | /* parent */ |
511 | USE_FOR_NOMMU(argv[-optind][0] &= 0x7f); /* undo fork_or_rexec() damage */ | ||
512 | xchdir(*argv++); | 511 | xchdir(*argv++); |
513 | close(pp.wr); | 512 | close(pp.wr); |
514 | xmove_fd(pp.rd, STDIN_FILENO); | 513 | xmove_fd(pp.rd, STDIN_FILENO); |
diff --git a/archival/unzip.c b/archival/unzip.c index ff4f6325c..7b945c250 100644 --- a/archival/unzip.c +++ b/archival/unzip.c | |||
@@ -56,7 +56,7 @@ | |||
56 | //kbuild:lib-$(CONFIG_UNZIP) += unzip.o | 56 | //kbuild:lib-$(CONFIG_UNZIP) += unzip.o |
57 | 57 | ||
58 | //usage:#define unzip_trivial_usage | 58 | //usage:#define unzip_trivial_usage |
59 | //usage: "[-lnojpq] FILE[.zip] [FILE]... [-x FILE]... [-d DIR]" | 59 | //usage: "[-lnojpqK] FILE[.zip] [FILE]... [-x FILE]... [-d DIR]" |
60 | //usage:#define unzip_full_usage "\n\n" | 60 | //usage:#define unzip_full_usage "\n\n" |
61 | //usage: "Extract FILEs from ZIP archive\n" | 61 | //usage: "Extract FILEs from ZIP archive\n" |
62 | //usage: "\n -l List contents (with -q for short form)" | 62 | //usage: "\n -l List contents (with -q for short form)" |
@@ -66,6 +66,7 @@ | |||
66 | //usage: "\n -p Write to stdout" | 66 | //usage: "\n -p Write to stdout" |
67 | //usage: "\n -t Test" | 67 | //usage: "\n -t Test" |
68 | //usage: "\n -q Quiet" | 68 | //usage: "\n -q Quiet" |
69 | //usage: "\n -K Do not clear SUID bit" | ||
69 | //usage: "\n -x FILE Exclude FILEs" | 70 | //usage: "\n -x FILE Exclude FILEs" |
70 | //usage: "\n -d DIR Extract into DIR" | 71 | //usage: "\n -d DIR Extract into DIR" |
71 | 72 | ||
@@ -497,6 +498,7 @@ int unzip_main(int argc, char **argv) | |||
497 | OPT_l = (1 << 0), | 498 | OPT_l = (1 << 0), |
498 | OPT_x = (1 << 1), | 499 | OPT_x = (1 << 1), |
499 | OPT_j = (1 << 2), | 500 | OPT_j = (1 << 2), |
501 | OPT_K = (1 << 3), | ||
500 | }; | 502 | }; |
501 | unsigned opts; | 503 | unsigned opts; |
502 | smallint quiet = 0; | 504 | smallint quiet = 0; |
@@ -560,9 +562,14 @@ int unzip_main(int argc, char **argv) | |||
560 | * 204372 1 file | 562 | * 204372 1 file |
561 | */ | 563 | */ |
562 | 564 | ||
565 | //TODO: accept and ignore these? | ||
566 | // -a convert to text files with 't' label, -aa: all files | ||
567 | // -b do not convert to text - bbox: we don't convert anything | ||
568 | // -D skip restoration of timestamps for extracted items - bbox: we don't restore these (yet?) | ||
569 | // -X restore user:group ownership | ||
563 | opts = 0; | 570 | opts = 0; |
564 | /* '-' makes getopt return 1 for non-options */ | 571 | /* '-' makes getopt return 1 for non-options */ |
565 | while ((i = getopt(argc, argv, "-d:lnotpqxjv")) != -1) { | 572 | while ((i = getopt(argc, argv, "-d:lnotpqxjvK")) != -1) { |
566 | switch (i) { | 573 | switch (i) { |
567 | case 'd': /* Extract to base directory */ | 574 | case 'd': /* Extract to base directory */ |
568 | base_dir = optarg; | 575 | base_dir = optarg; |
@@ -584,6 +591,7 @@ int unzip_main(int argc, char **argv) | |||
584 | xmove_fd(xopen("/dev/null", O_WRONLY), STDOUT_FILENO); | 591 | xmove_fd(xopen("/dev/null", O_WRONLY), STDOUT_FILENO); |
585 | /*fallthrough*/ | 592 | /*fallthrough*/ |
586 | 593 | ||
594 | // NB: -c extract files to stdout/screen (unlike -p, also prints .zip and file names to stdout) | ||
587 | case 'p': /* Extract files to stdout */ | 595 | case 'p': /* Extract files to stdout */ |
588 | dst_fd = STDOUT_FILENO; | 596 | dst_fd = STDOUT_FILENO; |
589 | /*fallthrough*/ | 597 | /*fallthrough*/ |
@@ -605,6 +613,10 @@ int unzip_main(int argc, char **argv) | |||
605 | opts |= OPT_j; | 613 | opts |= OPT_j; |
606 | break; | 614 | break; |
607 | 615 | ||
616 | case 'K': | ||
617 | opts |= OPT_K; | ||
618 | break; | ||
619 | |||
608 | case 1: | 620 | case 1: |
609 | if (!src_fn) { | 621 | if (!src_fn) { |
610 | /* The zip file */ | 622 | /* The zip file */ |
@@ -822,7 +834,10 @@ int unzip_main(int argc, char **argv) | |||
822 | # endif | 834 | # endif |
823 | if ((cdf.fmt.version_made_by >> 8) == 3) { | 835 | if ((cdf.fmt.version_made_by >> 8) == 3) { |
824 | /* This archive is created on Unix */ | 836 | /* This archive is created on Unix */ |
825 | dir_mode = file_mode = (cdf.fmt.external_attributes >> 16); | 837 | file_mode = (cdf.fmt.external_attributes >> 16); |
838 | if (!(opts & OPT_K)) | ||
839 | file_mode &= ~(mode_t)(S_ISUID | S_ISGID); | ||
840 | dir_mode = file_mode; | ||
826 | } | 841 | } |
827 | } | 842 | } |
828 | #endif | 843 | #endif |
@@ -847,6 +862,7 @@ int unzip_main(int argc, char **argv) | |||
847 | unzip_skip(zip.fmt.extra_len); | 862 | unzip_skip(zip.fmt.extra_len); |
848 | 863 | ||
849 | /* Guard against "/abspath", "/../" and similar attacks */ | 864 | /* Guard against "/abspath", "/../" and similar attacks */ |
865 | // NB: UnZip 6.00 has option -: to disable this | ||
850 | overlapping_strcpy(dst_fn, strip_unsafe_prefix(dst_fn)); | 866 | overlapping_strcpy(dst_fn, strip_unsafe_prefix(dst_fn)); |
851 | 867 | ||
852 | /* Filter zip entries */ | 868 | /* Filter zip entries */ |