Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-11-19 20:17:48 +0400
committerDenys Vlasenko <vda.linux@googlemail.com>2013-11-19 20:17:48 +0400
commit0545e3b69ab57af1c21d199611c56b7f7593c8c5 (patch)
treee085c0df969e977e3a6f1b247759d40eacf57129 /archival/tar.c
parentdd1d8ab506420014cf0a3a076b2e3a4fa5de16ee (diff)
tar: prevent empty file to be treated as valid tarball
function old new delta tar_main 879 895 +16 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/tar.c')
-rw-r--r--archival/tar.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 3877ea4db..bd61abd57 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -1196,8 +1196,14 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
/*tar_handle->offset = 0; - already is */
}
+ /* Zero processed headers (== empty file) is not a valid tarball.
+ * We (ab)use bb_got_signal as exitcode here,
+ * because check_errors_in_children() uses _it_ as error indicator.
+ */
+ bb_got_signal = EXIT_FAILURE;
+
while (get_header_tar(tar_handle) == EXIT_SUCCESS)
- continue;
+ bb_got_signal = EXIT_SUCCESS; /* saw at least one header, good */
/* Check that every file that should have been extracted was */
while (tar_handle->accept) {
@@ -1213,8 +1219,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
close(tar_handle->src_fd);
if (SEAMLESS_COMPRESSION || OPT_COMPRESS) {
+ /* Set bb_got_signal to 1 if a child died with !0 exitcode */
check_errors_in_children(0);
- return bb_got_signal;
}
- return EXIT_SUCCESS;
+
+ return bb_got_signal;
}