John Starks [Thu, 16 Nov 2017 00:10:49 +0000 (16:10 -0800)]
zip: Allow backslash as path separator
Some Windows zip archivers, such as PowerShell's Compress-Archive, use
backslash as the path separator in violation of the zip specification.
Info-Zip works around this by supporting this for archives that report
"version made by" of 0 (MS-DOS).
This change adds the same workaround to libarchive and adds a test of
this case using a zip file created with PowerShell.
John Starks [Thu, 2 Nov 2017 17:03:28 +0000 (10:03 -0700)]
Windows: set errno on CreateFileW failure
When CreateFileW fails in next_entry(), it reads from errno to set the
archive error, but errno is not set by CreateFileW. Add a call to
la_dosmaperr to set errno properly first.
Paul Spangler [Thu, 19 Oct 2017 19:33:12 +0000 (14:33 -0500)]
archive_write_disk_{posix,windows}.c: Don't modify attributes for existing directories when ARCHIVE_EXTRACT_NO_OVERWRITE is set
Enables unpacking multiple archives into a single directory whose permissions,
owner, and other attributes are pre-configured or otherwise determined ahead
of time by a single archive without the need to repeat the same attributes in
every archive, such as in package installation scenarios.
Signed-off-by: Paul Spangler <paul.spangler@ni.com>
ngie [Sun, 15 Oct 2017 17:59:07 +0000 (10:59 -0700)]
Fix a potential NULL pointer dereference of `tar` in archive_read_support_format_tar when HAVE_COPYFILE_H is defined (#959)
If HAVE_COPYFILE_H is defined and allocating tar via calloc fails, tar
would be dereferenced before the tar == NULL check is done, causing a
NULL pointer dereference. Move the HAVE_COPYFILE_H block after the NULL
dereference check.
(1) Do not double free a for the stdin case. Reported by Sean Purcell in
PR #904.
(2) Do not query errors after archive_read_free either, the memory is
gone. Split operation into close and read, reporting errors from the
former.
Brad King [Wed, 20 Sep 2017 14:19:38 +0000 (10:19 -0400)]
Do not use nanosecond file time APIs on macOS < 10.13
The SDK for macOS 10.13 adds `futimens` and `utimensat` so our checks
for these symbols may pass. However, the symbols are not available at
runtime on older macOS versions. Instead on macOS we can check for
availability based on the deployment target version.
jrmarino [Tue, 22 Aug 2017 13:46:29 +0000 (08:46 -0500)]
Recognize ".tzst" extension as ".tar.zst"
This follows convention establish by ".tgz", ".txz", etc.
The alias array was not sorted alphabetically (the only order seems to be grouping by decomposed extension), so the new element was just added to the end.
Tony Theodore [Sun, 13 Aug 2017 04:27:12 +0000 (14:27 +1000)]
libarchive.pc.in: add Cflags.private for static linking
`pkgconf` supports a `Cflags.private` that simplifies static linking
for windows (mingw cross) builds. Users of `pkg-config` will be
unaffected by this as existing build scripts will already set the
`-DLIBARCHIVE_STATIC` as required.
Colin Percival [Fri, 28 Jul 2017 23:28:50 +0000 (16:28 -0700)]
Avoid overflow when reading corrupt cpio archive
A cpio "newc" archive with a namelength of "FFFFFFFF", if read on a
system with a 32-bit size_t, would result in namelength + name_pad
overflowing 32 bits and libarchive attempting to copy 2^32-1 bytes
from a 2-byte buffer, with appropriately hilarious results.
Check for this overflow and fail; there's no legitimate reason for a
cpio archive to contain a file with a name over 4 billion characters
in length.
Reported by: Eyal Itkin
Security: Corrupt archives can cause libarchive to crash on
32-bit platforms.
Sponsored by: Tarsnap Backup Inc.
The LZX decoder flattens the Huffman tree into a table, but wanted to
limit it to 1k elements to reduce L1 pressure. Since the logic for
filling was flawed and performance argument points more to a bad index
logic, remove the tree logic.
Issue #901: Sparse files with long name get renamed.
The original ustar header has a 100 character limit for the file name.
With the POSIX interchange format, an additional header attribute
contains the full path and libarchive tries to cut it to something
sensible. The GNU sparse file extension on the other hand also likes to
mangle the ustar header field to include a marker and contains yet
another attribute for the original path. If the name was truncated
earlier, this attribute would get the incorrect truncated name.
Martin Matuska [Wed, 29 Mar 2017 21:16:02 +0000 (23:16 +0200)]
Report names of extended attributes that could not be restored
Remove xattr namespace limitations for AIX and Darwin
On Linux, skip all known ACL extended attributes and obsolete xfsroot