diff options
Diffstat (limited to 'archival')
-rw-r--r-- | archival/bbunzip.c | 9 | ||||
-rw-r--r-- | archival/libunarchive/decompress_unxz.c | 4 | ||||
-rw-r--r-- | archival/rpm2cpio.c | 4 |
3 files changed, 14 insertions, 3 deletions
diff --git a/archival/bbunzip.c b/archival/bbunzip.c index b243afb2e..832a7bbf3 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c @@ -373,6 +373,15 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv) static IF_DESKTOP(long long) int FAST_FUNC unpack_unxz(unpack_info_t *info UNUSED_PARAM) { + struct { + uint32_t v1; + uint16_t v2; + } magic; + xread(STDIN_FILENO, &magic, 6); + if (magic.v1 != XZ_MAGIC1a || magic.v2 != XZ_MAGIC2a) { + bb_error_msg("invalid magic"); + return -1; + } return unpack_xz_stream(STDIN_FILENO, STDOUT_FILENO); } int unxz_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; diff --git a/archival/libunarchive/decompress_unxz.c b/archival/libunarchive/decompress_unxz.c index 5d7513a2e..721acd907 100644 --- a/archival/libunarchive/decompress_unxz.c +++ b/archival/libunarchive/decompress_unxz.c @@ -56,9 +56,11 @@ unpack_xz_stream(int src_fd, int dst_fd) if (!crc32_table) crc32_table = crc32_filltable(NULL, /*endian:*/ 0); - membuf = xmalloc(2 * BUFSIZ); memset(&iobuf, 0, sizeof(iobuf)); + /* Preload XZ file signature */ + membuf = (void*) strcpy(xmalloc(2 * BUFSIZ), HEADER_MAGIC); iobuf.in = membuf; + iobuf.in_size = HEADER_MAGIC_SIZE; iobuf.out = membuf + BUFSIZ; iobuf.out_size = BUFSIZ; diff --git a/archival/rpm2cpio.c b/archival/rpm2cpio.c index 1f67fa887..b23d5afa9 100644 --- a/archival/rpm2cpio.c +++ b/archival/rpm2cpio.c @@ -92,8 +92,8 @@ int rpm2cpio_main(int argc UNUSED_PARAM, char **argv) xread(rpm_fd, magic.b32, sizeof(magic.b32[0])); if (magic.b32[0] != XZ_MAGIC2) goto no_magic; - /* unpack_xz_stream wants fd at position 0 */ - xlseek(rpm_fd, -6, SEEK_CUR); + /* unpack_xz_stream wants fd at position 6, no need to seek */ + //xlseek(rpm_fd, -6, SEEK_CUR); unpack = unpack_xz_stream; } else { no_magic: |