]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
3 years agoFix check for tape device 1640/head
Walter Lozano [Sat, 18 Dec 2021 01:44:09 +0000 (22:44 -0300)] 
Fix check for tape device

In b6b423f0 a fallback in tar to stdio was implemented. However, the check
for the tape device didn't interpret the correct value returned from
access(). Fix the check to implement the fallback to stdio properly.

Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
3 years agoupdate BLAKE2_PACKED macro with a non-GCCism fallback 1642/head
linear cannon [Sun, 19 Dec 2021 09:25:32 +0000 (01:25 -0800)] 
update BLAKE2_PACKED macro with a non-GCCism fallback

3 years agoupdate CMake sizeof definitions to match autotools 1641/head
linear cannon [Sun, 19 Dec 2021 08:25:57 +0000 (00:25 -0800)] 
update CMake sizeof definitions to match autotools

3 years agoimport m4_ax_compile_check_sizeof.m4 from autoconf archive
linear cannon [Sun, 19 Dec 2021 08:48:40 +0000 (00:48 -0800)] 
import m4_ax_compile_check_sizeof.m4 from autoconf archive

3 years agodefine printf format specifiers if not present
linear cannon [Sun, 19 Dec 2021 08:20:43 +0000 (00:20 -0800)] 
define printf format specifiers if not present

3 years agozip size entry of -1 should be treated the same as 0 1639/head
Todd Richmond [Sat, 18 Dec 2021 00:59:05 +0000 (16:59 -0800)] 
zip size entry of -1 should be treated the same as 0

3 years agoMerge pull request #1585 from JFranklin13/rar5_sfx
Martin Matuška [Wed, 15 Dec 2021 18:19:37 +0000 (19:19 +0100)] 
Merge pull request #1585 from JFranklin13/rar5_sfx

Add support for rar5 sfx files

3 years agoMerge pull request #1632 from wlozano0collabora/default-archive-file
Tim Kientzle [Sat, 4 Dec 2021 18:56:33 +0000 (10:56 -0800)] 
Merge pull request #1632 from wlozano0collabora/default-archive-file

Have `bsdtar` default to stdout if this system has no tape device.  This uses an `access()` check to see if the default tape device (e.g., `/dev/tape` on FreeBSD) exists and will use stdout as the default if it doesn't exist.  If the system does have a tape device, there is no change to the existing behavior.

For libarchive 4.0, we'll change the default behavior of `bsdtar`:
* The `TAPE` environment variable will still be honored at runtime
* The `_PATH_DEFTAPE` preprocessor macro will still be honored at build time
* But `_PATH_DEFTAPE` will no longer be set by libarchive's default build, with the effect that for most people, bsdtar will default to stdout if there is no `-f` option provided.

3 years agoAdd path fallback in tar 1632/head
Walter Lozano [Sat, 27 Nov 2021 00:23:20 +0000 (21:23 -0300)] 
Add path fallback in tar

Since current tar defaults to tape devices that are rare nowadays add an
additional step to fallback to "-" if tape devices are not found.

This is a clean way to have a default to "-" on those systems that tape
devices are not present while keeping the current behavior for other
cases. Additionally prepare for future releases where this kind of defaults
will be dropped.

Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
3 years agoMerge pull request #1626 from evelikov/bsdtar-allow-ax
Martin Matuška [Tue, 30 Nov 2021 23:30:08 +0000 (00:30 +0100)] 
Merge pull request #1626 from evelikov/bsdtar-allow-ax

tar: demote -xa from error to a warning

3 years agoMerge pull request #1633 from Changaco/patch-1
Martin Matuška [Tue, 30 Nov 2021 23:29:04 +0000 (00:29 +0100)] 
Merge pull request #1633 from Changaco/patch-1

Fix the archive_write_disk.3 man page

3 years agofix the archive_write_disk.3 man page 1633/head
Charly C [Sun, 28 Nov 2021 09:11:01 +0000 (10:11 +0100)] 
fix the archive_write_disk.3 man page

Some of the text was reordered incorrectly in a14fe904e2c63fefb99446980226a1bec4a95c5c.

3 years agoautotools: enable -fdata/function-sections and --gc-sections 1625/head
Emil Velikov [Sun, 21 Nov 2021 17:38:38 +0000 (17:38 +0000)] 
autotools: enable -fdata/function-sections and --gc-sections

Analogue to the parent cmake commit, with linker flag detection.

The former two split the functions and data into separate sections
within the object file. Which makes it easier for the latter to properly
garbage collect and discard unused sections.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agocmake: enable -fdata/function-sections and --gc-sections
Emil Velikov [Sun, 21 Nov 2021 17:38:28 +0000 (17:38 +0000)] 
cmake: enable -fdata/function-sections and --gc-sections

The former two split the functions and data into separate sections
within the object file. Which makes it easier for the latter to properly
garbage collect and discard unused sections. For example

   text    data     bss     dec     hex filename
 208268    2056    4424  214748   346dc bsdcat -- before
  93396    1304    4360   99060   182f4 bsdcat -- after
1059167   12112   24176 1095455  10b71f bsdcpio -- before
1002538    7320   23984 1033842   fc672 bsdcpio -- after
1093676   14248    6608 1114532  1101a4 bsdtar -- before
1062231   14176    6416 1082823  1085c7 bsdtar -- after
1097259   15032    6408 1118699  1111eb libarchive.so.18 -- before
1095675   14992    6216 1116883  110ad3 libarchive.so.18 -- after

Note:
This is enabled only with gcc/clang on non-Mac platforms. Ideally we'll
have a compile-time check, albeit that seems impossible with our ancient
cmake requirement.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agotar: demote -xa from error to a warning 1626/head
Emil Velikov [Sun, 21 Nov 2021 18:05:19 +0000 (18:05 +0000)] 
tar: demote -xa from error to a warning

It's fairly common for people to use caf and xaf on Linux. The former in
itself being GNU tar specific - libarchive tar does not allow xa.

While it makes little sense to use xaf with libarchive tar, that is
implementation detail which gets in the way when trying to write trivial
tooling/scripts.

For the sake of compatibility, reduce the error to a warning and augment
the message itself. Making it clear that the option makes little sense.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agocmake: drop -rdynamic aka CMP0065 NEW
Emil Velikov [Sun, 21 Nov 2021 14:50:25 +0000 (14:50 +0000)] 
cmake: drop -rdynamic aka CMP0065 NEW

Prior to version 3.3 cmake would always use -rdynamic. That in itself
causes all the internal symbols to be exported, increasing the binaries
by 5-10% and making it impossible for the compiler to reason, optimise
and discard unused code.

The -rdynamic is useful in two cases:
 - having a third party module (say /usr/lib/foo/foobar.so) which is
   underlinked and depends on symbols from the main binary - apps like
   irssi, bash and zsh use that

 - uses the glibc backtrace, which relies on dlopen/dlsym to fetch the
   symbol data. Unwind is much better solution, since it replies on the
   DWARF data

Our binaries do not use either of these - so drop the -rdynamic. The
autotools build doesn't use it either.

   text    data     bss     dec     hex filename
 229000    2120    4424  235544   39818 bsdcat -- before
 208324    2120    4424  214868   34754 bsdcat -- after
1093939   12128   24176 1130243  113f03 bsdcpio -- before
1059181   12128   24176 1095485  10b73d bsdcpio -- after
1130091   14264    6608 1150963  118ff3 bsdtar -- before
1093690   14264    6608 1114562  1101c2 bsdtar -- after

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agocmake: fold gcc/clang sections
Emil Velikov [Sun, 21 Nov 2021 14:26:53 +0000 (14:26 +0000)] 
cmake: fold gcc/clang sections

The flags used across the two are identical, apart from -g.
There is no compelling reason, why we would omit -g for debug builds
with GCC, while using it with clang.

De-duplicate the sections.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agoMerge pull request #1614 from diabonas/add-no-read-sparse
Martin Matuška [Sun, 21 Nov 2021 10:32:19 +0000 (11:32 +0100)] 
Merge pull request #1614 from diabonas/add-no-read-sparse

Add ARCHIVE_READDISK_NO_SPARSE/--no-read-sparse to improve reproducibility of generated archives

3 years agotest_sparse_basic: test ARCHIVE_READDISK_NO_SPARSE 1614/head
Jonas Witschel [Sat, 20 Nov 2021 10:37:50 +0000 (11:37 +0100)] 
test_sparse_basic: test ARCHIVE_READDISK_NO_SPARSE

3 years agotest_sparse_basic: do not assume that holes can be read in one go
Jonas Witschel [Sun, 21 Nov 2021 09:07:52 +0000 (10:07 +0100)] 
test_sparse_basic: do not assume that holes can be read in one go

verify_sparse_file() assumes that every hole will be fully contained in only
one archive_read_data_block(). This is a reasonable assumption if the file is
indeed sparsely encoded in the archive because archive_read_data_block() will
just skip the hole and return the offset of the next data block.

However, if the file is not sparsely encoded in the archive, a hole consists of
a lot of zeroes that need to be read byte by byte. In this case, the archive
contains no information on where this block of zeroes ends and where actual
data begins. Therefore it can happen that a single archive_read_data_block()
contains both zeroes from a hole and actual data.

If this happens, assert(sparse->type == HOLE) fails. This assertion is
reasonable for sparsely encoded files because archive_read_data_block() will
never only read part of a hole (since it does not really "read" a hole at all,
it just returns a higher offset accounting for the size of the hole).

However, we want to start testing files with verify_sparse_file() that are
explicitly not sparsely encoded. In this case, the assertion does not
necessarily hold any more. Therefore we need to account for the case where the
overlapping block consists of data. To make sure the file contents are
correctly encoded in the archive, we need to test the contents of the data
block, like it is already done for blocks completely contained in the data read
by archive_read_data_block().

Note that this modification does not change the way sparsely encoded files are
verified, it just relaxes an edge case that cannot happen with sparsely encoded
files to make it possible to test any kind of file, whether sparsely encoded or
not.

3 years agoMerge pull request #1621 from botovq/openssl_compat
Martin Matuška [Sat, 20 Nov 2021 23:19:57 +0000 (00:19 +0100)] 
Merge pull request #1621 from botovq/openssl_compat

Remove unnecessary OpenSSL compat ifdef.

3 years agoMerge pull request #1623 from DHowett/dev/duhowett/calling_convention
Martin Matuška [Sat, 20 Nov 2021 23:19:02 +0000 (00:19 +0100)] 
Merge pull request #1623 from DHowett/dev/duhowett/calling_convention

win32: specify the calling convention for functions that interact with libc

3 years agoMerge pull request #1622 from DHowett/dev/duhowett/user32
Martin Matuška [Sat, 20 Nov 2021 23:18:45 +0000 (00:18 +0100)] 
Merge pull request #1622 from DHowett/dev/duhowett/user32

win32: remove the hard dependency on user32.dll

3 years agoMerge pull request #1620 from rlibby/tar-cru-ignore-zeros
Martin Matuška [Sat, 20 Nov 2021 23:17:33 +0000 (00:17 +0100)] 
Merge pull request #1620 from rlibby/tar-cru-ignore-zeros

tar: respect --ignore-zeros in c r & u modes when reading archives

3 years agoRemove dependency on user32 1622/head
Dustin Howett [Wed, 13 Oct 2021 21:36:05 +0000 (14:36 -0700)] 
Remove dependency on user32

3 years agofix: include archive_platform in ...cpio to ensure calling convention 1623/head
Dustin Howett [Wed, 13 Oct 2021 21:35:40 +0000 (14:35 -0700)] 
fix: include archive_platform in ...cpio to ensure calling convention

3 years agowindows: make sure we use the right calling convention for libc
Dustin Howett [Wed, 13 Oct 2021 21:16:49 +0000 (14:16 -0700)] 
windows: make sure we use the right calling convention for libc

3 years agoRemove OpenSSL compat code that misuses the API 1621/head
Theo Buehler [Fri, 19 Nov 2021 17:55:29 +0000 (18:55 +0100)] 
Remove OpenSSL compat code that misuses the API

Immediately after EVP_CIPHER_CTX_new() neither EVP_CIPHER_CTX_init()
nor EVP_CIHPER_CTX_reset() should be called: the purpose of the init
function is to initialize a context on the stack while reset clears
a used context for reuse. Neither situation is the case here.

Removing the code also fixes a potential NULL dereference because an
error of reset is not signaled to the caller. Fortunately reset doesn't
currently fail in this situation in current OpenSSL and LibreSSL.

3 years agotar/test/test_option_ignore_zeros.c: test tar --ignore-zeros 1620/head
Ryan Libby [Fri, 19 Nov 2021 09:24:59 +0000 (01:24 -0800)] 
tar/test/test_option_ignore_zeros.c: test tar --ignore-zeros

Add some basic tests for operations on concatenated archives.

3 years agotar: respect --ignore-zeros in c r & u modes when reading archives
Ryan Libby [Fri, 19 Nov 2021 09:09:35 +0000 (01:09 -0800)] 
tar: respect --ignore-zeros in c r & u modes when reading archives

Previously, --ignore-zeros was only being applied to t and x modes.

3 years agoarchive_write_disk_posix: fix writing fflags broken in 8a1bd5c
Martin Matuska [Wed, 17 Nov 2021 20:06:00 +0000 (21:06 +0100)] 
archive_write_disk_posix: fix writing fflags broken in 8a1bd5c

The fixup list was erroneously assumed to be directories only.
Only in the case of critical file flags modification (e.g. SF_IMMUTABLE
on BSD systems), other file types (e.g. regular files or symbolic links)
may be added to the fixup list. We still need to verify that we are writing
to the correct file type, so compare the archive entry file type with
the file type of the file to be modified.

Fixes #1617

3 years agoMerge pull request #1588 from IohannRabeson/build_fixes
Martin Matuška [Tue, 16 Nov 2021 00:09:43 +0000 (01:09 +0100)] 
Merge pull request #1588 from IohannRabeson/build_fixes

Windows build fix

3 years agoMerge pull request #1591 from JiaT75/Added_documentation_for_exported_functions_in_ar...
Martin Matuška [Tue, 16 Nov 2021 00:01:17 +0000 (01:01 +0100)] 
Merge pull request #1591 from JiaT75/Added_documentation_for_exported_functions_in_archive_read_disk

Added documentation for exported functions in archive_read_disk

3 years agoMerge pull request #1598 from JiaT75/zip_entry_size_unset_store_fix_1547
Martin Matuška [Mon, 15 Nov 2021 23:59:49 +0000 (00:59 +0100)] 
Merge pull request #1598 from JiaT75/zip_entry_size_unset_store_fix_1547

Zip entry size unset now honors user requested compression level

3 years agoMerge pull request #1601 from evelikov/rm-fallthrough
Martin Matuška [Mon, 15 Nov 2021 23:54:51 +0000 (00:54 +0100)] 
Merge pull request #1601 from evelikov/rm-fallthrough

mtree reader: return early, remove fallthrough chain

3 years agoMerge pull request #1606 from JiaT75/clean_up_archive_read_disk_descend_functions
Martin Matuška [Mon, 15 Nov 2021 23:46:53 +0000 (00:46 +0100)] 
Merge pull request #1606 from JiaT75/clean_up_archive_read_disk_descend_functions

Cleaned up archive_read_disk_descend functions

3 years agoMerge pull request #1609 from JiaT75/added_error_message_to_warning_bsdtar_1561
Martin Matuška [Mon, 15 Nov 2021 23:45:36 +0000 (00:45 +0100)] 
Merge pull request #1609 from JiaT75/added_error_message_to_warning_bsdtar_1561

Added error text to warning when untaring with bsdtar

3 years agotar: expose ARCHIVE_READDISK_NO_SPARSE as --no-read-sparse
Jonas Witschel [Sun, 14 Nov 2021 17:56:49 +0000 (18:56 +0100)] 
tar: expose ARCHIVE_READDISK_NO_SPARSE as --no-read-sparse

3 years agoAdd ARCHIVE_READDISK_NO_SPARSE to suppress reading sparse file info
Jonas Witschel [Sun, 14 Nov 2021 17:56:49 +0000 (18:56 +0100)] 
Add ARCHIVE_READDISK_NO_SPARSE to suppress reading sparse file info

Sparse file information depends on the file system and can therefore be a
source of unreproducibility for the generated archives, e.g. if the same
content is compressed on a file system with and without sparse file support.
Add an option to suppress reading this information from disk entirely.

3 years agoAdded error message when archive extraction fails 1609/head
jiat75 [Sat, 30 Oct 2021 03:47:15 +0000 (11:47 +0800)] 
Added error message when archive extraction fails

3 years agoCleaned up archive_read_disk_descend functions. 1606/head
jiat75 [Wed, 27 Oct 2021 14:05:43 +0000 (22:05 +0800)] 
Cleaned up archive_read_disk_descend functions.

3 years agoFixing typo in archive_read_disk man page 1591/head
jiat75 [Wed, 27 Oct 2021 13:56:58 +0000 (21:56 +0800)] 
Fixing typo in archive_read_disk man page

3 years agoUsing the new .editorconfig to fix formatting on size unset store test 1598/head
jiat75 [Wed, 27 Oct 2021 12:43:48 +0000 (20:43 +0800)] 
Using the new .editorconfig to fix formatting on size unset store test

3 years agoReusing code from zip size known and adjusting comments
jiat75 [Wed, 27 Oct 2021 12:28:20 +0000 (20:28 +0800)] 
Reusing code from zip size known and adjusting comments

3 years agoMerge pull request #1602 from evelikov/editorconfig
Martin Matuška [Tue, 26 Oct 2021 12:22:23 +0000 (14:22 +0200)] 
Merge pull request #1602 from evelikov/editorconfig

editorconfig: add simple top-level file

3 years agoMerge pull request #1589 from JiaT75/added-missing-checks-for-canLzip-canLzma-and...
Martin Matuška [Tue, 26 Oct 2021 12:21:51 +0000 (14:21 +0200)] 
Merge pull request #1589 from JiaT75/added-missing-checks-for-canLzip-canLzma-and-canXz

added missing checks for canLzip, canLzma, and canXz

3 years agoMerge pull request #1590 from jsonn/master
Martin Matuška [Tue, 26 Oct 2021 12:03:10 +0000 (14:03 +0200)] 
Merge pull request #1590 from jsonn/master

Support ARCHIVE_EXTRACT_SECURE_NODOTDOT on Windows

3 years agoMerge pull request #1593 from JiaT75/added_bin_to_gitignore
Martin Matuška [Tue, 26 Oct 2021 11:51:25 +0000 (13:51 +0200)] 
Merge pull request #1593 from JiaT75/added_bin_to_gitignore

Added bin folder to .gitignore

3 years agoMerge pull request #1604 from AdamKorcz/fuzz1
Martin Matuška [Tue, 26 Oct 2021 11:24:03 +0000 (13:24 +0200)] 
Merge pull request #1604 from AdamKorcz/fuzz1

Add CIFuzz

3 years agoAdd CIFuzz 1604/head
AdamKorcz [Tue, 26 Oct 2021 10:10:08 +0000 (11:10 +0100)] 
Add CIFuzz

3 years agoreader: introduce struct archive_read_filter_vtable 1603/head
Emil Velikov [Sat, 14 Mar 2020 21:44:48 +0000 (21:44 +0000)] 
reader: introduce struct archive_read_filter_vtable

As before - move the dispatch/function pointer so a const data segment.
Separating it from the RW data section.

Note: the close function is _not_ optional - remove the NULL check.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agoreader: remove unused archive_read_filter callbacks
Emil Velikov [Sat, 14 Mar 2020 19:41:27 +0000 (19:41 +0000)] 
reader: remove unused archive_read_filter callbacks

In particular the ::open and ::sswitch callbacks are unused.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agoreader: track read_filter "can_skip" with a flag
Emil Velikov [Mon, 30 Mar 2020 22:13:15 +0000 (23:13 +0100)] 
reader: track read_filter "can_skip" with a flag

Analogous to the earlier "can_seek" change. Drop the function pointer
in favour of a flag. Over the years, with over a dozen filters, no
filters actually implemented it.

If at a point in the future that changes, one can reinstate it.

Alternatively one could use a ARCHIVE_FILTER_NONE check.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agoreader: track read_filter "can_seek" with a flag
Emil Velikov [Mon, 30 Mar 2020 21:54:21 +0000 (22:54 +0100)] 
reader: track read_filter "can_seek" with a flag

Currently we the ::seek callback can be either NULL or client_seek_proxy.

Since we already explicitly use the latter, instead of ::seek just drop
the function pointer all together, in favour of a simple flag.

Alternatively one could use a ARCHIVE_FILTER_NONE check.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agoreader: reuse client_{open,close}_proxy more
Emil Velikov [Sat, 14 Mar 2020 21:29:25 +0000 (21:29 +0000)] 
reader: reuse client_{open,close}_proxy more

Currently we have open-coded versions. Replace them with the respective
functions.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agoarchive: remove ::compression_{code,name}
Emil Velikov [Fri, 17 Apr 2020 21:13:54 +0000 (22:13 +0100)] 
archive: remove ::compression_{code,name}

These internal variables were set but never used. Remove them.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agoreader: transform get_bidder into register_bidder
Emil Velikov [Sat, 23 Oct 2021 17:22:05 +0000 (18:22 +0100)] 
reader: transform get_bidder into register_bidder

There's a notable duplication across all the read bidder code.

Check the archive magic/state, set the bidder private data (to NULL in
all but one case), name and vtable.

Change the helper to do the actual registration, keeping things simpler
in the dozen+ filters. This also allows us to enforce the bidder ::bid
and ::init dispatch are non NULL. The final one ::free is optional.

NOTE: some of the bidders do _not_ set a name, which I suspect is a
pre-existing bug. I've left them as-is, but we might want to fix and
enforce that somehow.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agoreader: introduce archive_read_filter_bidder::vtable
Emil Velikov [Sat, 14 Mar 2020 15:47:22 +0000 (15:47 +0000)] 
reader: introduce archive_read_filter_bidder::vtable

Provides a clear separation between RW data and RO executable code.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agoreader: remove the return type of archive_read_filter_bidder_vtable::free
Emil Velikov [Sun, 15 Mar 2020 15:44:26 +0000 (15:44 +0000)] 
reader: remove the return type of archive_read_filter_bidder_vtable::free

From over a dozen filters, only one instance has the vfunc... Always
returning ARCHIVE_OK.

Let's just remove the return type.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agoreader: remove archive_read_filter_bidder_vtable::free stubs
Emil Velikov [Sat, 14 Mar 2020 17:05:41 +0000 (17:05 +0000)] 
reader: remove archive_read_filter_bidder_vtable::free stubs

There is no point in having stubs around. The caller already checks if
the function pointer is NULL before calling it.

With this in place only one implementation remains in filter_program.

Technically we can rework/remove that as well, although the solution
might not be so clean, so let's keep that for another day.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agoreader: remove unused read_filter_bidder::options
Emil Velikov [Sat, 14 Mar 2020 16:01:11 +0000 (16:01 +0000)] 
reader: remove unused read_filter_bidder::options

None of the filters set ::options and based on git log, none of them
ever did despite that the API/infra was added over 10 years ago.

Let's just drop it, removing the majority of archive_set_filter_option()
which is essentially dead code.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agoarchive: constify the archive::vtable dispatch
Emil Velikov [Wed, 26 Feb 2020 16:11:38 +0000 (16:11 +0000)] 
archive: constify the archive::vtable dispatch

Currently we have a constant dispatch/vtable that we populate at runtime
for unknown reason.

Remove the functions doing all the work and use a simple static const
struct archive_vtable.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agoeditorconfig: add simple top-level file 1602/head
Emil Velikov [Sat, 23 Oct 2021 14:32:12 +0000 (15:32 +0100)] 
editorconfig: add simple top-level file

Add a simple top-level .editorconfig file to manage common attributes
such as indentation style, trailing whitespace and newline at end of
file. The format is wide spread and has support for nearly every editor
out there - see https://editorconfig.org/ for more.

Majority of the project is C - which uses tabs, although there are some
CMake files using 2 space indent and shell scripts - predominantly using
4 space indent.

This makes it harder for casual contributors to butcher things :-)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agomtree reader: return early, remove fallthrough chain 1601/head
Emil Velikov [Sat, 23 Oct 2021 13:42:55 +0000 (14:42 +0100)] 
mtree reader: return early, remove fallthrough chain

Remove the excessive fallthrough chain in parse_keyword(). Even though
it is in the else/error path, there is no point in comparing the key
another dozen (or more) times when we know it will fail.

Just use an early return (OK) or break respectively.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
3 years agoAdding test to Makefile.am
jiat75 [Tue, 19 Oct 2021 14:56:50 +0000 (22:56 +0800)] 
Adding test to Makefile.am

3 years agoAdded copyright to new test file.
jiat75 [Tue, 19 Oct 2021 14:33:10 +0000 (22:33 +0800)] 
Added copyright to new test file.

3 years agoAdded new test to cmake lists
jiat75 [Tue, 19 Oct 2021 13:45:58 +0000 (21:45 +0800)] 
Added new test to cmake lists

3 years agoAdded assertions for folder
jiat75 [Sun, 17 Oct 2021 02:37:22 +0000 (10:37 +0800)] 
Added assertions for folder

3 years agoAdded test for writing an zip file without entry size and no compression
jiat75 [Sun, 17 Oct 2021 01:52:13 +0000 (09:52 +0800)] 
Added test for writing an zip file without entry size and no compression

3 years agoOnly use deflate when size is not set if the user did not specify a compression algorithm
jiat75 [Sat, 16 Oct 2021 07:33:25 +0000 (15:33 +0800)] 
Only use deflate when size is not set if the user did not specify a compression algorithm

3 years agoAdd support for rar5 sfx files 1585/head
JFranklin13 [Thu, 14 Oct 2021 11:53:16 +0000 (13:53 +0200)] 
Add support for rar5 sfx files

3 years agoAdded bin folder to .gitignore 1593/head
jiat75 [Sat, 9 Oct 2021 05:58:44 +0000 (13:58 +0800)] 
Added bin folder to .gitignore

3 years agoRemoved unused function. 1589/head
jiat75 [Thu, 7 Oct 2021 14:43:08 +0000 (22:43 +0800)] 
Removed unused function.

3 years agoAdded all exported but undocumented functions to man pages
jiat75 [Wed, 6 Oct 2021 10:58:44 +0000 (18:58 +0800)] 
Added all exported but undocumented functions to man pages

3 years agoSupport ARCHIVE_EXTRACT_SECURE_NODOTDOT on Windows 1590/head
Joerg Sonnenberger [Wed, 6 Oct 2021 22:24:30 +0000 (00:24 +0200)] 
Support ARCHIVE_EXTRACT_SECURE_NODOTDOT on Windows

3 years agoadd test 1503/head
Wei-Cheng Pan [Thu, 30 Sep 2021 12:20:21 +0000 (21:20 +0900)] 
add test

3 years agoadded missing checks for canLzip, canLzma, and canXz
jiat75 [Sun, 3 Oct 2021 07:23:28 +0000 (15:23 +0800)] 
added missing checks for canLzip, canLzma, and canXz

3 years agosupport rar filters
Wei-Cheng Pan [Mon, 15 Feb 2021 16:08:55 +0000 (01:08 +0900)] 
support rar filters

3 years agoMake all the implicit cast explicit. 1588/head
IohannRabeson [Sun, 3 Oct 2021 06:07:37 +0000 (02:07 -0400)] 
Make all the implicit cast explicit.

To prevent conversion warning preventing to build on Windows.

3 years agoMerge pull request #1575 from Hello71/patch-1
Martin Matuška [Thu, 30 Sep 2021 13:41:29 +0000 (15:41 +0200)] 
Merge pull request #1575 from Hello71/patch-1

libarchive.3: update archive format list

3 years agoMerge pull request #1567 from russelltg/russell_zstd_threads
Martin Matuška [Thu, 30 Sep 2021 11:20:05 +0000 (13:20 +0200)] 
Merge pull request #1567 from russelltg/russell_zstd_threads

zstd filter writer: add threads option

3 years agoMerge pull request #1569 from ferivoz/dir
Martin Matuška [Thu, 30 Sep 2021 11:17:34 +0000 (13:17 +0200)] 
Merge pull request #1569 from ferivoz/dir

Ignore size of directories with regular type

3 years agolibarchive.3: update archive format list 1575/head
Alex Xu [Fri, 17 Sep 2021 02:33:55 +0000 (02:33 +0000)] 
libarchive.3: update archive format list

Add 7-Zip and WARC to read formats, add many compressors, sort lists in approximate lexicographical order.

3 years agoAdded test case for ustar directory handling 1569/head
Samanta Navarro [Sun, 29 Aug 2021 11:59:29 +0000 (11:59 +0000)] 
Added test case for ustar directory handling

Based on test_compat_tar_hardlink.c and with input by Tim Kientzle.

3 years agoMerge pull request #1570 from ferivoz/mac
Martin Matuška [Sat, 4 Sep 2021 22:28:16 +0000 (00:28 +0200)] 
Merge pull request #1570 from ferivoz/mac

Fix size_t cast in read_mac_metadata_blob

3 years agoIgnore size of directories with regular type
Samanta Navarro [Sat, 28 Aug 2021 11:53:24 +0000 (11:53 +0000)] 
Ignore size of directories with regular type

In old tar formats directories are specified by appending a slash to
their names.

Directories may have sizes, but they do not have data blocks. Keep this
in mind and avoid skipping data blocks when encountering directories.

3 years agoFix size_t cast in read_mac_metadata_blob 1570/head
Samanta Navarro [Sat, 28 Aug 2021 11:58:00 +0000 (11:58 +0000)] 
Fix size_t cast in read_mac_metadata_blob

The size_t data type on 32 bit systems is smaller than int64_t. Check
the int64_t value before casting to size_t. If the value is too large
then stop operation instead of continuing operation with truncated
value.

3 years agoarchive_write_set_format_cpio_binary: fix compilation on OpenBSD
Martin Matuska [Fri, 27 Aug 2021 16:04:59 +0000 (18:04 +0200)] 
archive_write_set_format_cpio_binary: fix compilation on OpenBSD

Rename swap16 and swap32 to la_swap16 and la_swap32.

3 years agoFix following symlinks when processing the fixup list
Martin Matuska [Fri, 27 Aug 2021 08:56:28 +0000 (10:56 +0200)] 
Fix following symlinks when processing the fixup list

The previous fix in b41daecb5 was incomplete. Fixup entries are
given the original path without calling cleanup_pathname().
To make sure we don't follow a symlink, we must strip trailing
slashes from the path.

The fixup entries are always directories. Make sure we try to modify
only directories by providing O_DIRECTORY to open() (if supported)
and if it fails to check directory via lstat().

Fixes #1566

3 years agofix --threads commandline 1567/head
Russell Greene [Wed, 25 Aug 2021 17:26:48 +0000 (13:26 -0400)] 
fix --threads commandline

3 years agozstd filter writer: add threads option
Russell Greene [Wed, 25 Aug 2021 16:09:19 +0000 (12:09 -0400)] 
zstd filter writer: add threads option

3 years agoCI: provide a more complete Ubuntu package list
Martin Matuska [Sun, 22 Aug 2021 23:06:27 +0000 (01:06 +0200)] 
CI: provide a more complete Ubuntu package list

3 years agoLibarchive 3.5.3dev
Martin Matuska [Sun, 22 Aug 2021 22:50:26 +0000 (00:50 +0200)] 
Libarchive 3.5.3dev

3 years agoRelease 3.5.2 v3.5.2
Martin Matuska [Sun, 22 Aug 2021 15:33:36 +0000 (17:33 +0200)] 
Release 3.5.2

3 years agoSkip archive_write_disk_fixup test on Windows
Martin Matuska [Sun, 22 Aug 2021 13:53:31 +0000 (15:53 +0200)] 
Skip archive_write_disk_fixup test on Windows

3 years agoDo not follow symlinks when processing the fixup list
Martin Matuska [Thu, 19 Aug 2021 23:50:27 +0000 (01:50 +0200)] 
Do not follow symlinks when processing the fixup list

Use lchmod() instead of chmod() and tell the remaining functions that the
real file to be modified is a symbolic link.

Fixes #1566

3 years agoNever follow symlinks when setting file flags on Linux
Martin Matuska [Sun, 22 Aug 2021 01:53:28 +0000 (03:53 +0200)] 
Never follow symlinks when setting file flags on Linux

When opening a file descriptor to set file flags on linux, ensure
no symbolic links are followed. This fixes the case when an archive
contains a directory entry followed by a symlink entry with the same
path. The fixup code would modify file flags of the symlink target.

3 years agoFix handling of symbolic link ACLs
Martin Matuska [Sat, 21 Aug 2021 18:51:07 +0000 (20:51 +0200)] 
Fix handling of symbolic link ACLs

On Linux ACLs on symbolic links are not supported.
We must avoid calling acl_set_file() on symbolic links as their
targets are modified instead.

While here, do not try to set default ACLs on non-directories.

Fixes #1565

3 years agowrite_disk_posix: rename variable in check_symlinks_fsobj()
Martin Matuska [Sat, 21 Aug 2021 07:07:54 +0000 (09:07 +0200)] 
write_disk_posix: rename variable in check_symlinks_fsobj()

Rename the flag "extracting_hardlink" to "checking_linkname" to
be more accurate about its use. If the variable is non-zero it
means that check_symlinks_fsobj() is called on the linkname
when a hardlink is going to be created.

3 years agoFix extracting hardlinks to symlinks
Martin Matuska [Fri, 20 Aug 2021 23:39:31 +0000 (01:39 +0200)] 
Fix extracting hardlinks to symlinks

On platforms that support the linkat(2) function we can safely
write hardlinks to symlinks as linkat(2) does not follow symlinks
by default.

Fixes #1044