diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2012-03-06 16:33:42 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-03-06 16:33:42 +0100 |
commit | faac1d3e6e87dc6882e69b62f1c71907d892c876 (patch) | |
tree | c9feb257a4d47e71a5555360b0978e22c9e37dbf /archival/tar.c | |
parent | 02c3c3842004d88207b46450dbd19f80e6596c7e (diff) | |
download | busybox-w32-faac1d3e6e87dc6882e69b62f1c71907d892c876.tar.gz busybox-w32-faac1d3e6e87dc6882e69b62f1c71907d892c876.tar.bz2 busybox-w32-faac1d3e6e87dc6882e69b62f1c71907d892c876.zip |
tar,rpm2cpio: check that child decompressor did not error out
function old new delta
check_errors_in_children - 57 +57
tar_main 833 848 +15
get_header_tar 1720 1733 +13
rpm2cpio_main 147 140 -7
handle_SIGCHLD 41 - -41
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 2/1 up/down: 85/-48) Total: 37 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/tar.c')
-rw-r--r-- | archival/tar.c | 38 |
1 files changed, 7 insertions, 31 deletions
diff --git a/archival/tar.c b/archival/tar.c index af38ac59f..cf972c24c 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -690,29 +690,6 @@ static llist_t *append_file_list_to_list(llist_t *list) | |||
690 | # define append_file_list_to_list(x) 0 | 690 | # define append_file_list_to_list(x) 0 |
691 | #endif | 691 | #endif |
692 | 692 | ||
693 | #ifdef CHECK_FOR_CHILD_EXITCODE | ||
694 | /* Looks like it isn't needed - tar detects malformed (truncated) | ||
695 | * archive if e.g. bunzip2 fails */ | ||
696 | static int child_error; | ||
697 | |||
698 | static void handle_SIGCHLD(int status) | ||
699 | { | ||
700 | /* Actually, 'status' is a signo. We reuse it for other needs */ | ||
701 | |||
702 | /* Wait for any child without blocking */ | ||
703 | if (wait_any_nohang(&status) < 0) | ||
704 | /* wait failed?! I'm confused... */ | ||
705 | return; | ||
706 | |||
707 | if (WIFEXITED(status) && WEXITSTATUS(status) == 0) | ||
708 | /* child exited with 0 */ | ||
709 | return; | ||
710 | /* Cannot happen? | ||
711 | if (!WIFSIGNALED(status) && !WIFEXITED(status)) return; */ | ||
712 | child_error = 1; | ||
713 | } | ||
714 | #endif | ||
715 | |||
716 | //usage:#define tar_trivial_usage | 693 | //usage:#define tar_trivial_usage |
717 | //usage: "-[" IF_FEATURE_TAR_CREATE("c") "xt" | 694 | //usage: "-[" IF_FEATURE_TAR_CREATE("c") "xt" |
718 | //usage: IF_FEATURE_SEAMLESS_Z("Z") | 695 | //usage: IF_FEATURE_SEAMLESS_Z("Z") |
@@ -1059,10 +1036,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
1059 | if (base_dir) | 1036 | if (base_dir) |
1060 | xchdir(base_dir); | 1037 | xchdir(base_dir); |
1061 | 1038 | ||
1062 | #ifdef CHECK_FOR_CHILD_EXITCODE | 1039 | //if (SEAMLESS_COMPRESSION || OPT_COMPRESS) |
1063 | /* We need to know whether child (gzip/bzip/etc) exits abnormally */ | 1040 | // /* We need to know whether child (gzip/bzip/etc) exits abnormally */ |
1064 | signal(SIGCHLD, handle_SIGCHLD); | 1041 | // signal(SIGCHLD, check_errors_in_children); |
1065 | #endif | ||
1066 | 1042 | ||
1067 | /* Create an archive */ | 1043 | /* Create an archive */ |
1068 | if (opt & OPT_CREATE) { | 1044 | if (opt & OPT_CREATE) { |
@@ -1118,9 +1094,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
1118 | if (ENABLE_FEATURE_CLEAN_UP /* && tar_handle->src_fd != STDIN_FILENO */) | 1094 | if (ENABLE_FEATURE_CLEAN_UP /* && tar_handle->src_fd != STDIN_FILENO */) |
1119 | close(tar_handle->src_fd); | 1095 | close(tar_handle->src_fd); |
1120 | 1096 | ||
1121 | #ifdef CHECK_FOR_CHILD_EXITCODE | 1097 | if (SEAMLESS_COMPRESSION || OPT_COMPRESS) { |
1122 | return bb_got_signal; | 1098 | check_errors_in_children(0); |
1123 | #else | 1099 | return bb_got_signal; |
1100 | } | ||
1124 | return EXIT_SUCCESS; | 1101 | return EXIT_SUCCESS; |
1125 | #endif | ||
1126 | } | 1102 | } |