diff options
author | Ron Yorston <rmy@pobox.com> | 2024-11-08 12:48:57 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-11-08 13:08:47 +0000 |
commit | 0e958a72e1780138e68c799792190085cf505ee7 (patch) | |
tree | a8febeac10f73ab1ca9d0c9a5d5f1fe1b581496c | |
parent | bd258eabf2931024c5c24f9c11ce192cdaf23bd5 (diff) | |
download | busybox-w32-0e958a72e1780138e68c799792190085cf505ee7.tar.gz busybox-w32-0e958a72e1780138e68c799792190085cf505ee7.tar.bz2 busybox-w32-0e958a72e1780138e68c799792190085cf505ee7.zip |
tar: try harder to detect old tar files
The code to autodetect compressed tar files failed to detect a
bunzip2-compressed archive. When tar was invoked with the 'j'
option it worked fine.
The autodetection code looks for the magic string 'ustar' or a
series of five NULs to determine that an archive is uncompressed.
The failing archives had more than five NULs in the header and
were taken to be uncompressed.
Look for a longer run of NULs: 16 is certainly sufficient for the
archives in question.
Adds 8-16 bytes.
(GitHub issue #475)
-rw-r--r-- | archival/libarchive/get_header_tar.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/archival/libarchive/get_header_tar.c b/archival/libarchive/get_header_tar.c index cc6f3f0ad..5fd5a7980 100644 --- a/archival/libarchive/get_header_tar.c +++ b/archival/libarchive/get_header_tar.c | |||
@@ -239,8 +239,13 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle) | |||
239 | /* Check header has valid magic, "ustar" is for the proper tar, | 239 | /* Check header has valid magic, "ustar" is for the proper tar, |
240 | * five NULs are for the old tar format */ | 240 | * five NULs are for the old tar format */ |
241 | if (!is_prefixed_with(tar.magic, "ustar") | 241 | if (!is_prefixed_with(tar.magic, "ustar") |
242 | #if !ENABLE_PLATFORM_MINGW32 | ||
242 | && (!ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY | 243 | && (!ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY |
243 | || memcmp(tar.magic, "\0\0\0\0", 5) != 0) | 244 | || memcmp(tar.magic, "\0\0\0\0", 5) != 0) |
245 | #else | ||
246 | && (!ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY | ||
247 | || memcmp(tar.magic, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) != 0) | ||
248 | #endif | ||
244 | ) { | 249 | ) { |
245 | #if ENABLE_FEATURE_TAR_AUTODETECT | 250 | #if ENABLE_FEATURE_TAR_AUTODETECT |
246 | autodetect: | 251 | autodetect: |