aboutsummaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
Diffstat (limited to 'archival')
-rw-r--r--archival/bbunzip.c7
-rw-r--r--archival/libarchive/decompress_bunzip2.c9
2 files changed, 14 insertions, 2 deletions
diff --git a/archival/bbunzip.c b/archival/bbunzip.c
index 9c1a73780..853c653c0 100644
--- a/archival/bbunzip.c
+++ b/archival/bbunzip.c
@@ -103,7 +103,9 @@ int FAST_FUNC bbunpack(char **argv,
status = unpacker(&info);
if (status < 0)
exitcode = 1;
- xclose(STDOUT_FILENO); /* with error check! */
+
+ if (!(option_mask32 & OPT_STDOUT))
+ xclose(STDOUT_FILENO); /* with error check! */
if (filename) {
char *del = new_name;
@@ -143,6 +145,9 @@ int FAST_FUNC bbunpack(char **argv,
}
} while (*argv && *++argv);
+ if (option_mask32 & OPT_STDOUT)
+ xclose(STDOUT_FILENO); /* with error check! */
+
return exitcode;
}
diff --git a/archival/libarchive/decompress_bunzip2.c b/archival/libarchive/decompress_bunzip2.c
index cd3144743..c4640d489 100644
--- a/archival/libarchive/decompress_bunzip2.c
+++ b/archival/libarchive/decompress_bunzip2.c
@@ -752,7 +752,14 @@ unpack_bz2_stream(int src_fd, int dst_fd)
}
}
- if (i != RETVAL_LAST_BLOCK) {
+ if (i != RETVAL_LAST_BLOCK
+ /* Observed case when i == RETVAL_OK:
+ * "bzcat z.bz2", where "z.bz2" is a bzipped zero-length file
+ * (to be exact, z.bz2 is exactly these 14 bytes:
+ * 42 5a 68 39 17 72 45 38 50 90 00 00 00 00).
+ */
+ && i != RETVAL_OK
+ ) {
bb_error_msg("bunzip error %d", i);
break;
}