Martin Matuska [Fri, 6 Nov 2020 02:17:11 +0000 (03:17 +0100)]
Introduce archive_write_open2() with free callback
The archive_write_open() function does not provide a free callback.
Freeing was done by the close callback. When the open callback fails,
the client filter is left in ARCHIVE_WRITE_FILTER_STATE_FATAL,
the close callback is not called and unfreed resources may be left behind.
HBSD: Teach libarchive about the system extended attribute namespace
In order to teach the packaging infrastructure how to support
HardenedBSD's method of exploit mitigation toggling, teach libarchive
how to handle the system filesystem extended attribute namespace.
Shawn Webb [Sun, 9 Aug 2020 12:15:06 +0000 (08:15 -0400)]
HBSD: wrap function declaration in an ifdef to appease CI
The function I added only applies to FreeBSD. As such, if the function
declaration isn't ifdef'd out for other architectures, continuous
integration (CI) builds fail. Mitigate the failure by guarding the
function declaration with the proper preprocessor macro conditional.
HBSD: Teach libarchive about the system extended attribute namespace
In order to teach HardenedBSD's packaging infrastructure how to support
HardenedBSD's method of exploit mitigation toggling, teach libarchive
how to handle the system filesystem extended attribute namespace.
Luis Henriques [Fri, 25 Sep 2020 09:09:44 +0000 (10:09 +0100)]
Fix test clean-up
On test clean-up an 'rm -rf' will fail because 'lock' and 'lock/lock2'
directories have 0311 permissions. Change these permissions on exit so
that the directories can be deleted on success.
Alex Richardson [Thu, 17 Sep 2020 17:14:58 +0000 (18:14 +0100)]
Avoid mismatch between library and test crypto configuration
I was investigating libarchive test failures on FreeBSD and it turns out
we get a reproducible SIGBUS for test_archive_m5, etc. Debugging this shows
that libarchive and the tests disagree when it comes to the definition of
archive_md5_ctx: libarchive assumes it's the OpenSSL type whereas the test
use the libmd type. The latter is not necessarily aligned enough to store
a pointer (16 bytes for CHERI RISC-V), so we were crashing when storing
EVP_MD_CTX* to an 8-byte-aligned archive_md5_ctx.
To avoid problems like this in the future, add a new macro to the config
header and use that to ensure that all configuration check macros have
been defined in archive_digest_private.h.
use O_TMPFILE if it works/is supported in __archive_mktemp
This makes the function safer on linux since the file is warrantied to never
be visible on the filesystem, cannot be linked anywhere unless O_EXCL is
not specified and it is lost forever on any kind of program termination.
Yichao Yu [Sun, 28 Jun 2020 15:29:45 +0000 (11:29 -0400)]
Set an error message for setting invalid format by code on readers
The error message is consistent with `archive_read_set_format`.
The absense of an error message here also means that the error message
in `archive_read_set_format` is actually never used.
Writer functions does not seem to have the same issue.
Steve Pieper [Sun, 7 Jun 2020 14:25:31 +0000 (10:25 -0400)]
COMP: explicitly handle all enum cases in switch
In VisualStudio 2019 error C4061 happens if you don't
have a case statement for every value of an enum.
The default condition is not enough.
This fix avoids error like this:
25>C:\sq5\LibArchive\libarchive\archive_read_support_format_warc.c(344,2): error C4061: enumerator 'WT_NONE' in switch of enum 'warc_type_t' is not explicitly handled by a case label [C:\sq5\LibArchive-build\libarchive\archive.vcxproj]
Yichao Yu [Sun, 31 May 2020 18:30:10 +0000 (14:30 -0400)]
Complete support for UTF8 encoding conversion
All the conversions already always go through the MBS form so
simply always convert to MBS before trying to convert to any other encoding
in the `archive_mstring_get_*` functions.
* Do this by calling `archive_mstring_get_mbs` to avoid duplicating code
* Add `struct archive*` parameter to `archive_mstring_get_mbs_l`
* Add test for set/get/update utf8 functions on entry
* Add test for encoding conversion.
Michael Forney [Fri, 29 May 2020 21:54:05 +0000 (14:54 -0700)]
Fix rdev field in cpio format for device nodes
Currently, the rdev field is set from archive_entry_dev, which is
the device number of the filesystem containing the device node, not
the device itself. It should instead use archive_entry_rdev.
Here's an example demonstrating the problem:
$ ls -l /dev/null
crw-rw-rw- 1 root root 1, 3 May 26 02:03 /dev/null
$ bsdtar --format=cpio -cf null.cpio /dev/null
bsdtar: Removing leading '/' from member names
$ bsdtar -tvf null.cpio
crw-rw-rw- 1 0 0 0,6 May 26 02:03 dev/null
goshhhy [Sun, 24 May 2020 23:17:44 +0000 (14:17 -0900)]
configure.ac: check if flags are needed for c99
some older and more obscure compilers (e.g. mipspro on irix) default to the strictest standard they know instead of the most permissive. since libarchive uses c99 features in several places throughout, but does not pass appropriate cflags to parse c99 code, it will fail to compile from the configure script on these systems. this change will have autoconf check if any flags are needed for the c compiler to accept c99 code, and add them to cflags.
Michał Górny [Sat, 23 May 2020 19:54:53 +0000 (21:54 +0200)]
test_read_append_filter_wrong_program: Do not check stderr
Do not assert on specific output of bunzip2. This wrongly assumes
that all systems will be using the reference implementation of bzip2,
and it fails when an implementation with another output is used
(e.g. lbzip2).
Stefan Baranoff [Tue, 19 May 2020 00:57:14 +0000 (00:57 +0000)]
Fix memory leak from passphrase callback
There is a bug in the linked list implementation for passphrases. The insert to
head function does not account for the tail==head case and causes a leak. The
first entry into the list is lost when the second entry is added. The second
and beyond entries are are released properly, but the first is lost entirely.
Emil Velikov [Sat, 14 Mar 2020 13:31:31 +0000 (13:31 +0000)]
Remove #ifdef chain in __archive_digest init
Follow the approach set by the crypto and use the exact same name for
the respective functions. This is perfectly fine, since only one
provider can be used (built) at given time.
As a result, we can kill off the excessively long ifdef chain, making
the more more manageable and shorter.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>