diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-10-11 14:11:44 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-10-21 16:54:40 +0200 |
commit | ebc1c38a9295228b35c99e03c2377c717703469e (patch) | |
tree | aab4a1c80eb53839566e071237eb00b51ba263e4 /archival | |
parent | be11940911363a73fc4e74d759d0b472447daabc (diff) | |
download | busybox-w32-ebc1c38a9295228b35c99e03c2377c717703469e.tar.gz busybox-w32-ebc1c38a9295228b35c99e03c2377c717703469e.tar.bz2 busybox-w32-ebc1c38a9295228b35c99e03c2377c717703469e.zip |
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.c | 20 | ||||
-rw-r--r-- | archival/libarchive/unxz/xz_stream.h | 2 |
2 files changed, 20 insertions, 2 deletions
diff --git a/archival/libarchive/decompress_unxz.c b/archival/libarchive/decompress_unxz.c index 8ae7a275b..948ef978c 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" |