aboutsummaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
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)
96 */ 96 */
97 do { 97 do {
98 if (membuf[iobuf.in_pos] != 0) { 98 if (membuf[iobuf.in_pos] != 0) {
99 /* There is more data, but is it XZ data?
100 * Example: dpkg-deb -f busybox_1.30.1-4_amd64.deb
101 * reads control.tar.xz "control" file
102 * inside the ar archive, but tar.xz
103 * extraction code reaches end of xz data,
104 * reached this code and reads the beginning
105 * of data.tar.xz's ar header, which isn't xz data,
106 * and prints "corrupted data".
107 * The correct solution is to not read
108 * past nested archive (to simulate EOF).
109 * This is a workaround:
110 */
111 if (membuf[iobuf.in_pos] != 0xfd) {
112 /* It's definitely not a xz signature
113 * (which is 0xfd,"7zXZ",0x00).
114 */
115 goto end;
116 }
99 xz_dec_reset(state); 117 xz_dec_reset(state);
100 goto do_run; 118 goto do_run;
101 } 119 }
@@ -128,7 +146,7 @@ unpack_xz_stream(transformer_state_t *xstate)
128 break; 146 break;
129 } 147 }
130 } 148 }
131 149 end:
132 xz_dec_end(state); 150 xz_dec_end(state);
133 free(membuf); 151 free(membuf);
134 152
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 @@
25 25
26#define STREAM_HEADER_SIZE 12 26#define STREAM_HEADER_SIZE 12
27 27
28#define HEADER_MAGIC "\3757zXZ" 28#define HEADER_MAGIC "\375""7zXZ"
29#define HEADER_MAGIC_SIZE 6 29#define HEADER_MAGIC_SIZE 6
30 30
31#define FOOTER_MAGIC "YZ" 31#define FOOTER_MAGIC "YZ"