496 Commits
Author SHA1 Message Date
Duncan Horn f75ed3a205 Fix a number of Windows/clang(-cl) issues 2026-08-05 16:44:08 -07:00
Dan Nelson e8154e0bfc tar: add --mode option (compatible with gnutar) 2026-08-01 15:11:08 -05:00
Dustin L. Howett 89efbd80de build: add ENABLE_CLANG_TIDY and CLANG_TIDY_PATH 2026-07-04 14:42:26 -05:00
Tobias Stoeckmann 37b0b5a502 unzip: Add Windows port
Copy missing functionality from libarchive and cpio.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-06-24 18:02:15 +02:00
Tobias Stoeckmann 16be338523 Add archive_integer.h
The archive_integer.h header offers various integer operations to
libarchive, utilizing system functionality where possible.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-06-12 23:32:36 +02:00
Dustin L. Howett 81385b8864 Merge pull request #2954 from ShelpAm/master
fix: zstd not found on Windows
2026-06-09 09:55:46 -05:00
KongQBin 9938302f67 build: fix global state leakage in crypto/library checks
The CMake build script was modifying global CMake variables (CMAKE_REQUIRED_LIBRARIES
and CMAKE_REQUIRED_INCLUDES) during crypto library checks (OpenSSL, MbedTLS, Nettle)
and Haiku libbsd checks without saving/restoring them using
CMAKE_PUSH_CHECK_STATE() and CMAKE_POP_CHECK_STATE().

This caused side effects where subsequent system-level checks (like
CHECK_TYPE_SIZE or CHECK_FUNCTION_EXISTS) inherited these library dependencies,
leading to incorrect feature detection in cross-compilation environments
(e.g., reporting that basic types like 'pid_t' are missing).

This patch ensures all such checks are properly scoped, improving build
robustness across different architectures (x86_64, AArch64, MIPS64, LoongArch64, etc.)
and cross-toolchain environments.
2026-05-26 09:24:31 +08:00
Tim Kientzle a1b525e654 Fix CMake style 2026-05-06 23:24:53 -07:00
Tim Kientzle f833d13e6d Fix CMake-based testing 2026-05-06 22:02:15 -07:00
Tim Kientzle 2f5ed45e4c [CMake] Automatically update list.h
`list.h` contains a list of all the tests and is generated
by grepping the test source files for `DEFINE_TEST`.
Previously, it was generated at configure time.
This meant that if you added a new test to an existing
source file, you had to manually reconfigure.

This adds the necessary dependencies so that `list.h`
is regenerated whenever any C test source changes.
This ensures that new tests are always discovered automatically.

Note:  If someone wants to update the autoconf-based
build system to do this, please send a PR.
2026-05-05 20:54:12 -07:00
Dag-Erling Smørgrav 7364e380bc configure: On Darwin, get digests from libsystem
Darwin covers a wide range of platforms with similar but not identical
sets of libraries.  MD5, SHA1 and SHA2 are available from libsystem on
all of these, but macOS also has them in libc and libmd.  Restricting
our search to only libsystem means we can run configure on macOS and get
a config.h that also works for other Darwin platforms.
2026-05-02 12:49:02 +02:00
ShelpAm e8d363a09d fix: zstd not found
On Windows, zstd is sometimes named `zstd_static`.
2026-04-09 15:26:12 +08:00
Tobias Stoeckmann d99f5ebadf Add missing HAVE_STDIO_H cmake check
The check is performed by configure, but not with cmake. The
bsdunzip/la_getline.c file checks for presence of this definition.
2026-03-16 09:42:19 +01:00
Josh Carp 3ff73fdfce Skip unsupported linker options on illumos.
Building on illumos currently fails with:

```
ld: fatal: unrecognized option '--gc-sections'
```

This happens because `--gc-sections` isn't supported on illumos `ld`.
This patch updates CMakeLists.txt to skip unsupported linker options on
illumos. The flags used on other operating systems are optimizations
that don't affect correctness, so this change is safe.
2025-12-31 22:37:01 +00:00
Gabriel Barrantes 8f3fcf9ecd Improve wording 2025-12-21 17:30:42 -06:00
Dag-Erling Smørgrav 8fff509f1a Replace system() with posix_spawn() if available
Some platforms disallow system() due to its perceived insecurity.
Luckily, we can be just as insecure using the more palatable
posix_spawn() instead!
2025-10-14 19:17:53 +02:00
Dag-Erling Smørgrav e12c955dca Unify temporary directory handling
In archive_util.c, we have a private function named get_tempdir() which
is used by __archive_mktemp() to get the temporary directory if the
caller did not pass one.

In archive_read_disk_entry_from_file.c, we use the same logic with a
slight twist (don't trust the environment if setugid) to create a
temporary file for metadata.

Merge the two by renaming get_tempdir() to __archive_get_tempdir() and
unstaticizing it (with a prototype in archive_private.h).
2025-10-13 16:58:44 +02:00
Dustin L. Howett 619e22cae7 WIP: remove WinCrypt support
I am debating whether to remove the checks for bcrypt as well (it is
supported on all versions of Windows currently targeted.)

fixes https://github.com/libarchive/libarchive/issues/2595
2025-09-22 16:05:17 -05:00
Tim Kientzle ab4d21e4cb Merge pull request #2707 from fdegros/close_range_support
Avoid leaking file descriptors into subprocesses
2025-08-20 11:18:45 -07:00
Dag-Erling Smørgrav a335429c5e Drop support for readdir_r()
There has never been a good reason to prefer it over readdir(), and it
has now been marked obsolete in POSIX-1.2024.
2025-08-01 17:07:17 +02:00
François Degros 64bcf69ef8 Use closefrom() or close_range() when possible
To avoid leaking file descriptors into subprocesses.

Fixes: https://github.com/libarchive/libarchive/issues/2520
2025-07-31 15:03:22 +10:00
Kraust d2d72ac78a Allow Compiling Against Static CRT. 2025-07-13 22:57:25 -04:00
Dan Yeaw 4984c652db Fix .pc location when CMAKE_INSTALL_LIBDIR not set 2025-06-18 21:27:04 -04:00
Steve Lhomme ac96967e36 [cmake] add uuid library when using xmllite
Consecutive to 16fd043f51
IID_ISequentialStream is required by the code.
This GUID is defined in uuid.lib or libuuid.a in mingw-w64. It is required
to link with that library to get the definition of the GUID. Some toolchains
add it by default but not all.
2025-05-26 10:44:49 +02:00
Dustin L. Howett 16fd043f51 xar: add xmllite support to the XAR reader and writer (#2388)
This commit adds support for reading and writing XAR archives on Windows
using the built-in xmllite library. xmllite is present in all versions
of Windows starting with Windows XP.

With this change, no external XML library (libxml2, expat) is required
to read or produce XAR archives on Windows.

xmllite is a little bit annoying in that it's entirely a COM API--the
likes of which are annoying to use from C.

Signed-off-by: Dustin L. Howett <dustin@howett.net>
Depends on e619342dfa
Closes #1811
2025-05-09 13:40:21 +02:00
Christoph Grüninger 3a5a34b821 [cmake] Require CMake 3.17 or newer (#2556)
Remove code for older versions of CMake.
CMake 3.14 stopped running on Windows XP and Vista.

Fix detection of wcscmo, wcscpy, wcslen
2025-03-28 18:06:15 -07:00
Christoph Grüninger 4237b476fd [cmake] Require minimum CMake version of 3.5 (#2555)
CMake 4.0 will be released soon and it refuses to accept a minimum
required version below 3.5 without additional flags.
2025-03-26 06:18:12 -07:00
ljdarj 52e0bfd750 archive_version_details' update (#2349)
Adding missing librairies to `archive_version_details()`'s output. I put
"system" if the library doesn't give a way to query its version and
"bundled" if there's a choice between the system copy of a library and a
bundled one and we took the bundled copy (Only one library in that case,
libb2. Maybe also xxhash in the future?).

I would have a question for the Windows specialists though: is there a
way to query the interface version of a CNG cryptographic provider?
Because I know of a way for Crypto API providers but I haven't found any
for CNG ones, despite `<bcrypt.h>` having an interface version
structure.

Fixes #2300.
2025-03-07 19:28:51 -08:00
Mostyn Bramley-Moore 7708713b63 Suppress macOS CC_MD5_* deprecation warnings in the autoconf build too (#2473)
This also limits the amount of code where deprecation warnings are
suppressed.

Previously these warnings were only suppressed in the cmake build.
2025-01-01 15:30:37 -08:00
Zeun 4ebca5ff83 Fix -Werror=warning error and wrap some INSTALL directives with an ENABLE_INSTALL guard (#2397)
1. Fixes build when compiling without ZLIB/BZIP/LZMA `char finishing`
2. All INSTALL directives are now guarded by ENABLE_INSTALL
2024-12-27 12:53:13 -08:00
Julian Uy 819c5b01a9 Check for tcgetattr / tcsetattr before using it for readpassphrase implementation (#2424)
This is mainly for non-cygwin newlib platforms that don't have tcgetattr
/ tcsetattr implemented
2024-12-06 07:58:58 -08:00
Mostyn Bramley-Moore ae23713ceb 7zip writer: initial support for zstandard compression (#2137)
This is intended to be compatible with:
* https://github.com/mcmilk/7-Zip-zstd
* https://github.com/tehmul/p7zip-zstd
2024-10-22 11:01:55 +02:00
vcoxvcoandvco e2c512a59f configure.ac,CMakeLists.txt: Add libbsd on Haiku for readpassphrase (#2352)
Followup from #2346 

Add libbsd to make/cmake configuration for linking readpassphrase on
Haiku.
Maybe there is a better way to do this for cmake, I'm not that familiar
with it.

Co-authored-by: vco <god@universe.sys>
2024-10-12 17:44:32 -07:00
Martin Matuska 915c9f83a4 Libarchive 3.8.0dev 2024-09-13 23:13:01 +02:00
Martin Matuska 12ecf8418a Release 3.7.5 2024-09-13 22:20:55 +02:00
Mostyn Bramley-Moore f3670277f7 cmake: do not require zlib (#2327)
Followup to #2318 which accidentally made zlib required.

Tested locally by increasing the version in CMakeLists.txt to 1.4.1
(which does not exist yet), and confirming that the build reports that a
suitable version of zlib was not found, while the build continued..
2024-09-13 21:28:05 +02:00
3f1b5340d9 Fix SOVERSION computation logic in CMake to match libtool's (#1976)
Fix SOVERSION computation logic in CMake to match libtool's

Closes #1857 

Co-authored-by: isuruf <isuruf@users.noreply.github.com>
Co-authored-by: Timothy Lyanguzov <theta682@gmail.com>
2024-09-13 21:24:48 +02:00
Mostyn Bramley-Moore 6df5cb464b cmake: look for zlib >= 1.2.1 (#2318)
zlib 1.2.0 added this improvement for inflate:
"Raw inflate no longer needs an extra dummy byte at end"

libarchive does not feed zlib extra data beyond end of stream, so it
does not work with zlib < 1.2.0.
2024-09-12 23:56:34 +02:00
Mrmaxmeier bea3a56118 Fuzzing: Expose DONT_FAIL_ON_CRC_ERROR as a CMake option and honor it in the rar5 decoder (#2229)
Hey,

the fuzzing infrastructure over at OSSFuzz builds libarchive with the
CMake option `-DDONT_FAIL_ON_CRC_ERROR=1`.

https://github.com/google/oss-fuzz/blob/e4643b64b3af4932bff23bb87afdfbac2a301969/projects/libarchive/build.sh#L35
This, unfortunatly, does not do anything since it's never been defined
as an option.

Building the fuzzers with CRC checks disabled should improve fuzzing
efficacy a bunch.

Thanks!
2024-06-12 11:57:20 -07:00
Sevan Janiyan 3f3b3efec2 Always use our supplied la_queue.h (#2222)
On legacy systems the OS supplied `sys/queue.h` may lack the required
macros, so to avoid having to verify if the version of queue.h is of
use, opt to always to `la_queue.h` which will match expectations.

Allows libarchive to build on legacy Darwin where `STAILQ_FOREACH` would
be missing from `sys/queue.h`.

Resolves #2220
2024-06-10 20:42:13 -07:00
Duncan Horn 89a01843ee Fix compilation when using Clang in "MSVC mode" (#2221)
When using Clang in "MSVC mode" (i.e. clang-cl), command line arguments
are interpreted as MSVC would interpret them, at least when there are
conflicts. This means that `-Wall` - potentially among other switches -
is interpreted _dramatically_ differently by clang-cl compared to
"normal" Clang.

In CMake, this can be detected by testing for `if (MSVC)` in addition to
compiler id test, which is what I do here.

Note: this is a partial cherry-pick from #2095, which I'm going to go
through and break into smaller pieces in hopes of getting some things in
while discussion of other things can continue.
2024-06-08 12:41:04 -07:00
Martin Matuska 9951b9cd25 Libarchive 3.7.5dev 2024-04-26 12:07:47 +02:00
Martin Matuska 313aa1fa10 Release 3.7.4 2024-04-26 11:22:15 +02:00
Dag-Erling SmørgravandMartin Matuska 3efcadf886 zstd: Implement core detection (#2083)
The bsdtar manual page claims that setting zstd:threads to 0 tells zstd
to use as many threads as there are cores in the system, but it actually
disables multi-threading.  Replace 0 with the number of configured
processors.

While here, add a previously missing overflow check.

Co-authored-by: Martin Matuska <martin@matuska.de>
2024-04-23 15:11:40 +02:00
evan-swinney 5daa209cfa Change CMAKE_BUILD_TYPE comparison to be case-insensitive (#2130)
Currently the `CMAKE_BUILD_TYPE` is being compared in a case-sensitive
way. It seems current CMake documentation [suggests treating this in a
case-insensitive manner
now-a-days](https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#case-sensitivity).

This being case-sensitive creates needless complexities in other
projects if they compile their own project with `cmake
-DCMAKE_BUILD_TYPE=release ..`, etc. In this specific case, libarchive
has a fatal error due to the lowercase `release`.

I'd honestly like to remove these comparisons entirely; as I'm not sure
if they're really needed or not if `libarchive` is only using the
Makefile or Ninja generators with CMake.

This PR changes the `CMAKE_BUILD_TYPE` comparison to be
case-insensitive, and leaves the rest alone.

This should also fix the following issue(s):
* https://github.com/libarchive/libarchive/issues/1792
2024-04-16 20:51:30 -07:00
Martin Matuska b3be94ba4f Libarchive 3.7.4dev 2024-04-08 12:17:17 +02:00
Martin Matuska 4fcc02d906 Release 3.7.3 2024-04-08 00:11:03 +02:00
Tim Kientzle 771f434c90 build: use standard HAVE_ pattern for ZSTD compression check (#2111)
Follow-on to #1649: this just changes the name of the preprocessor macro
to use the standard pattern HAVE_<function name>

In particular: newer ZSTD implementations have a growing variety of
compression functions; the standard pattern will make it easier to
select among those someday.
2024-04-07 23:45:21 +02:00
Martin Matuska 2b12cb429c cmake: look for libxml2 only if HAVE_ICONV is set (#2105)
Signed-off-by: Duncan Horn
2024-04-01 19:43:52 +02:00
Collin Funk dcfef34f0c cmake: Set CMP0075 to NEW (#2067)
The new behavior of this policy makes check_include_file() and friends
use the CMAKE_REQUIRED_LIBRARIES variable before checking for headers.
This is used to check for cryptography algorithms provided by OpenSSL.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>
2024-03-23 18:17:09 +01:00