aboutsummaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-10-11 14:11:44 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2019-10-11 14:11:44 +0200
commit42f454b13b8d972e85acd7f046065ec69af4d206 (patch)
tree2cc09f3970a5115bee0fccda3c558a1e9211660f /archival
parent7011eca83afc313098f9869eea36742d4506bc02 (diff)
downloadbusybox-42f454b13b8d972e85acd7f046065ec69af4d206.tar.gz
dpkg-deb: work around bogus error message when working with XZ compressed packages
function old new delta unpack_xz_stream 2309 2317 +8 bb_full_fd_action 464 472 +8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival')
-rw-r--r--archival/libarchive/decompress_unxz.c20
-rw-r--r--archival/libarchive/unxz/xz_stream.h2
2 files changed, 20 insertions, 2 deletions
diff --git a/archival/libarchive/decompress_unxz.c b/archival/libarchive/decompress_unxz.c
index f03341384..3dd9bbf49 100644
--- a/archival/libarchive/decompress_unxz.c
+++ b/archival/libarchive/decompress_unxz.c
@@ -96,6 +96,24 @@ unpack_xz_stream(transformer_state_t *xstate)
*/
do {
if (membuf[iobuf.in_pos] != 0) {
+ /* There is more data, but is it XZ data?
+ * Example: dpkg-deb -f busybox_1.30.1-4_amd64.deb
+ * reads control.tar.xz "control" file
+ * inside the ar archive, but tar.xz
+ * extraction code reaches end of xz data,
+ * reached this code and reads the beginning
+ * of data.tar.xz's ar header, which isn't xz data,
+ * and prints "corrupted data".
+ * The correct solution is to not read
+ * past nested archive (to simulate EOF).
+ * This is a workaround:
+ */
+ if (membuf[iobuf.in_pos] != 0xfd) {
+ /* It's definitely not a xz signature
+ * (which is 0xfd,"7zXZ",0x00).
+ */
+ goto end;
+ }
xz_dec_reset(state);
goto do_run;
}
@@ -128,7 +146,7 @@ unpack_xz_stream(transformer_state_t *xstate)
break;
}
}
-
+ end:
xz_dec_end(state);
free(membuf);
diff --git a/archival/libarchive/unxz/xz_stream.h b/archival/libarchive/unxz/xz_stream.h
index 66cb5a705..45056e42c 100644
--- a/archival/libarchive/unxz/xz_stream.h
+++ b/archival/libarchive/unxz/xz_stream.h
@@ -25,7 +25,7 @@
#define STREAM_HEADER_SIZE 12
-#define HEADER_MAGIC "\3757zXZ"
+#define HEADER_MAGIC "\375""7zXZ"
#define HEADER_MAGIC_SIZE 6
#define FOOTER_MAGIC "YZ"