Dynamically determine supported compiler flags during configure
Some compilers (e.g., `xlc` on AIX) don't support GCC compiler flags.
This change dynamically tests for supported `COMMON_FLAGS`, which get
appended to `CFLAGS`.
Signed-off-by: Eric N. Vander Weele <ericvw@gmail.com>
Andrew Gregory [Fri, 15 Jan 2016 07:39:41 +0000 (02:39 -0500)]
Skip root directory symlink check
The first time check_symlinks is called on an absolute path it will use
the entry pathname directly, blanking the leading slash. This leads to
calling lstat on an empty string, which returns ENOENT, terminating the
loop early and falsely marking the path as safe.
Andrew Gregory [Fri, 15 Jan 2016 07:40:00 +0000 (02:40 -0500)]
Restore modified path after lstat
check_symlinks is intended to check each component of a path, but failed
to restore the stripped trailing components after each iteration,
leaving a NUL byte in the middle of the path.
Tim Kientzle [Sun, 21 Feb 2016 20:34:57 +0000 (12:34 -0800)]
Fix for issue #623.
Apparently, people have come to expect that the following
is sufficient to get bit-for-bit identical output from tar:
* Same filenames
* Same contents
* Same uid, gid
* Same mtime (forced via "touch -t <timestamp>")
* Sorting entries
Bsdtar's "restricted pax" format violated this by including
ctime, atime, and birthtime (which are not updated by
'touch -t). So we should only emit those additional time
values in the full pax format.
People who are really serious about generating bit-for-bit
identical archives should really build their own command-line
interface: You can still use libarchive to build the output,
but your custom CLI could sort the entries and strip everything
except a bare minimum of basic metadata.
Tim Kientzle [Sun, 14 Feb 2016 05:52:24 +0000 (21:52 -0800)]
Issue #659: Fix xar parsing of archives with appleextended ACLs
The parser treated the <appleextended> tag as both known and
unknown, leaving the parser in a state that prevented it
from reading any further attributes. Depending on the
order of attributes, this could result in a file with no
name, for instance.
Tim Kientzle [Mon, 1 Feb 2016 05:43:23 +0000 (21:43 -0800)]
Read very large RAR headers incrementally
Formerly, libarchive tried to read the entire header into
memory at once, which created problems for malformed RAR
files with 4GB header sizes. This was causing occasional
crashes of the test suite on memory-limited systems.
Tim Kientzle [Tue, 19 Jan 2016 13:32:56 +0000 (05:32 -0800)]
Fix nettle library probe
= Only use it if we can find the library *and* the headers
= When probing the library, try to link a function that's
actually in the library (not 'main')
Sean Farley [Sun, 3 Jan 2016 21:42:00 +0000 (16:42 -0500)]
Apply global flag in substitution
Add loop to move through a path name looking for additional matches if
the global flag is provided for a substitution. The loop breaks when no
more matches are found for the rule. Previously, the global flag would
end up advancing to the next rule instead of searching farther into the
path for another match.
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.
Paul Barker [Sat, 26 Sep 2015 18:38:13 +0000 (19:38 +0100)]
Issue 578: Close temp_fd in 7zip and xar writers
The ISO9660 writer uses a temp_fd and closes it in the archive_free handler. The
same logic is added to the archive_free handlers for the 7zip and xar writers.
Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
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.