Brad King [Wed, 21 Oct 2015 16:02:43 +0000 (12:02 -0400)]
Forward declare __archive_get_date in a dedicated internal header
Avoid repeating the signature declaration in every source that uses it.
While at it, constify internal __archive_get_date implementation to
keep signatures consistent.
Brad King [Wed, 21 Oct 2015 15:56:28 +0000 (11:56 -0400)]
Use macros for ZIP format integer constants
Define ZIP_4GB_MAX and ZIP_4GB_MAX_UNCOMPRESSED macros to hold the "LL"
integer literals. This improves readability and improves portability of
the integer literals.
Brad King [Wed, 21 Oct 2015 15:59:45 +0000 (11:59 -0400)]
Invert logic of ternary pointer checks
A PGI compiler warning is triggered by expressions like
ptr == NULL ? NULL : ptr
that the PGI compiler handles incorrectly. It chooses the pointer type
of the first option (void*) and warns about conversion of the second
without a cast. Flip the expression logic to
ptr != NULL ? ptr : NULL
to help the compiler choose the proper result type.
Brad King [Wed, 21 Oct 2015 15:59:45 +0000 (11:59 -0400)]
Improve readability of ternary expression checking for empty string
In expressions of the form
m != NULL && m[0] == '\0' ? NULL : m
the goal is to get a `NULL` pointer if `m` is either `NULL` or an empty
string. This is not clear because in the `m == NULL` case we use the
`m` side to get `NULL` instead of an explicit `NULL`. Clarify the
intent by using the form
Brad King [Wed, 21 Oct 2015 16:02:21 +0000 (12:02 -0400)]
Avoid left-shift overflow of signed integer
In libarchive/archive_write_set_format_zip.c there are two calls to
archive_le32enc whose second argument is of the form
archive_entry_mode(zip->entry) << 16
However, the return type from archive_entry_mode may be a signed integer
so the shift may overflow. Since the second argument of archive_le32enc
expects uint32_t anyway, simply cast to that prior to shifting.
Tim Kientzle [Sun, 6 Sep 2015 05:43:09 +0000 (22:43 -0700)]
Rework the la_ssize_t and la_int64_t definitions to avoid
redefining la_int64_t if both archive.h and archive_entry.h are
included. (This avoids a warning from clang that redefining
a typedef is a C11 feature.)
Graham Percival [Sun, 30 Aug 2015 17:53:12 +0000 (10:53 -0700)]
Warn if target of hard-link is not present
To reproduce,
touch a
ln a b
./bsdtar -c -f warn-hard-links.tar a b
rm a b
./bsdtar -x -f warn-hard-links.tar b
should produce a warning message about failing to create 'b' because the
hard-link target 'a' does not exist. Previously, it did not give any hints
about why 'b' could not be created.
Tim Kientzle [Thu, 27 Aug 2015 15:42:02 +0000 (08:42 -0700)]
Issue 593: Add .travis.yml for Travis-CI
This will help people who want to use Travis-CI to follow
libarchive development. Including Travis-CI status in the
README.md is a separate issue that requires one of the
libarchive maintainers to commit to managing it.
Tim Kientzle [Sun, 9 Aug 2015 04:47:43 +0000 (21:47 -0700)]
Issue 547: problems with compress bidder
The code previously was not very careful about verifying the
compression parameters. This led to cases where it failed to
reject invalid compressed data at the beginning. The invalid
left shift was one symptom of this.
The code is now more careful: It verifies that the compression
parameter byte exists and verifies that the maximum code size
is <= 16 bits.
This also includes some new tests to verify that truncated or
otherwise invalid compressed data is rejected.
Tim Kientzle [Sun, 9 Aug 2015 03:52:19 +0000 (20:52 -0700)]
Issue 551: Fix the best-effort UTF8 conversion
If a valid character set conversion is impossible, the code falls back
to a best-effort conversion that preserves ASCII bytes and converts
the rest to Unicode Replacement Characters (if the output is UTF8)
or '?' (otherwise). This code did not correctly track the remaining
bytes in the output buffer; I've replaced this with slower and simpler
code that utilizes the safe string append functions.
configure.ac: Use pkg-config to find libxml2. Fixes cross compilation
This was originally submitted to Google Code, and was carried over
during GitHub migration; however, it was in patch form, so I've made
a pull request for it for quicker merging.
Original source: https://github.com/libarchive/libarchive/issues/407
Original author: ambrop7
When you need to write a callback for archive_read_open2, you must provide a
function which has the same signature as the typedef. The documentation says
that the read callback returns a ssize_t, but on windows there is no such
ssize_t. libarchive falls back on another type and use the private macro
__LA_SSIZE_T, thus it is not possible to write portable code that use
read_open2.
This patch replaces that macro with a simple typedef la_ssize_t (and does the
same for la_int64_t).
Brooks Davis [Tue, 10 Feb 2015 17:43:10 +0000 (17:43 +0000)]
Add a new tar option --clear-nochange-fflags that causes file system
flags which might prevent the removal or modifiction of files to
be cleared before attempting to remove them.