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>
David Capello [Sat, 18 Apr 2020 18:09:43 +0000 (15:09 -0300)]
Use /w1nnnn instead of /wennnn to enable warnings on MSVC Debug mode
On MSVC /wennnn treats the specific warning number nnnn as an error:
https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level
But we want to enable this only when ENABLE_WERROR is defined (so the
general /WX flag is enough to treat all warnings as errors instead of
using /we).
Martin Matuska [Mon, 2 Mar 2020 07:55:44 +0000 (08:55 +0100)]
Safe writes: improve error handling
Print message if creation of temporary file fails.
When rename of temporary file fails, exit with ARCHIVE_FAILED.
Reword message on failed rename.
Revert d84ec3f and 85b9f66, call archive_set_error()w before unlinking.
Ward Vandewege [Fri, 14 Feb 2020 02:56:09 +0000 (21:56 -0500)]
New ASCII format: fix hard link description
The description of how hard links are handled in the 'new ASCII format' is wrong. Cpio stores the *first*, not *last* copy of the file with its entire contents, followed by entries with filesize set to zero for each subsequent entry that is hard linked. While creating the archive, how would it ever know it was processing the last one!
Brad King [Thu, 6 Feb 2020 19:28:02 +0000 (14:28 -0500)]
Fix possible heap-buffer-overflow in archive_string_append_from_wcs on Windows
Fix `archive_string_append_from_wcs_in_codepage` to account for the
already-used portion of the buffer when computing the size of the
remaining buffer for `WideCharToMultiByte` output.
RAR5 reader: reject files that declare invalid header flags
One of the fields in RAR5's base block structure is the size of the
header. Some invalid files declare a 0 header size setting, which can
confuse the unpacker. Minimum header size for RAR5 base blocks is 7
bytes (4 bytes for CRC, and 3 bytes for the rest), so block size of 0
bytes should be rejected at header parsing stage.
The fix adds an error condition if header size of 0 bytes is detected.
In this case, the unpacker will not attempt to unpack the file, as the
header is corrupted.
The commit also adds OSSFuzz #20459 sample to test further regressions
in this area.