Compare commits

...

493 Commits

Author SHA1 Message Date
Martin Matuška
8d1c9b95f1
Merge pull request #2838 from DHowett/revert-2826-waitpid
Revert "Wait for the process instead of busy wait loop"
2026-01-07 23:38:30 +01:00
Dustin L. Howett
dea03d6e00
Revert "Wait for the process instead of busy wait loop" 2026-01-07 13:42:41 -08:00
Martin Matuška
3cd503b75a
Merge pull request #2781 from AZero13/ints
Remove unneeded int cast
2026-01-05 10:35:59 +01:00
Martin Matuška
86851e3092
Merge pull request #2826 from AZero13/waitpid
Wait for the process instead of busy wait loop
2026-01-05 10:33:33 +01:00
Martin Matuška
02eba33825
Merge pull request #2836 from ngie-eign/add-freebsd-15-cirrus-ci
Expand the test matrix to include 15.x images/ZFS
2026-01-05 10:32:49 +01:00
Enji Cooper
0bb2058bd5 Expand the test matrix to include 15.x images/ZFS
This change adds support for the following test scenarios:

- 15.0-RELEASE - ZFS
- 15.0-STABLE - UFS
- 15.0-STABLE - ZFS

This additional testing aims to catch issues with 15.x, as well as
ensure libarchive use doesn't regress when run on ZFS-based hosts.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
2026-01-04 17:55:34 -08:00
Tim Kientzle
e663efb430
Merge pull request #2835 from jmcarp/build-illumos
Skip unsupported linker options on illumos.
2025-12-31 15:31:55 -08: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
Tim Kientzle
e91171c9a0
Merge pull request #2825 from AZero13/patch-2
Error check ret before calling copy_seek_stat
2025-12-27 10:52:17 -08:00
Tim Kientzle
7f27446a51
Merge pull request #2824 from AZero13/qosflags
Remove bitmask typo in dwSecurityQosFlags
2025-12-27 10:48:03 -08:00
Tim Kientzle
090fbc3655
Merge pull request #2827 from AZero13/free
Simplify file free
2025-12-27 10:31:27 -08:00
Tim Kientzle
8c2241a7e4
Merge pull request #2829 from AZero13/leak-shar
archive_write_shar_header: free shar->last_dir before replacement
2025-12-27 10:30:22 -08:00
Tim Kientzle
d54b2241b9
Merge pull request #2830 from AZero13/return
return early if archive_write_set_format_shar fails
2025-12-27 10:28:27 -08:00
Tim Kientzle
782cdd88b6
Merge pull request #2831 from AZero13/check-copy-length
Use copy_length as upper-bound, not strlen(p)
2025-12-27 10:27:12 -08:00
Tim Kientzle
d1b87af584
Merge pull request #2834 from AZero13/patch-5
Use #warning, not #warn
2025-12-27 10:21:44 -08:00
AZero13
9a089dc44a archive_write_shar_header: free shar->last_dir before replacement 2025-12-26 18:05:03 -05:00
AZero13
a55b8e8aec
Use #warning, not #warn
#warn is a GNU extension
2025-12-26 15:28:12 -05:00
AZero13
76558692a4 Use copy_length as upper-bound, not strlen(p) 2025-12-26 15:09:10 -05:00
AZero13
4a32d9ff7f return early if archive_write_set_format_shar fails 2025-12-26 15:05:46 -05:00
AZero13
998c0b4080 Simplify file free
free is fine if NULL
2025-12-26 14:45:42 -05:00
AZero13
030a93817c Wait for the process instead of busy wait loop 2025-12-26 13:54:21 -05:00
AZero13
9298dc503a
Error check ret before calling copy_seek_stat 2025-12-26 13:29:14 -05:00
AZero13
e54c735586 Remove bitmask typo in dwSecurityQosFlags
We seemed to have been isolating the wrong flags.
2025-12-26 13:19:56 -05:00
Martin Matuška
b2d68e2f1a
Merge pull request #2813 from AZero13/memcpy
We copy from p, not p + module_len
2025-12-26 10:22:13 +01:00
Martin Matuška
1cd0b9179c
Merge pull request #2796 from vcoxvco/fix_unninit
libarchive/archive_util.c: Uninitialized variable
2025-12-25 10:16:46 +01:00
Martin Matuška
095609e89b
Merge pull request #2816 from AZero13/strdup
Error check strdup for path name
2025-12-25 10:14:23 +01:00
Martin Matuška
5c84afd664
Merge pull request #2814 from AZero13/gname
uname_override checks gname_override when it should check uname_override
2025-12-25 10:04:44 +01:00
Martin Matuška
f366e98107
Merge pull request #2789 from libarchive/dependabot/github_actions/all-actions-50b857948b
CI: Bump the all-actions group across 1 directory with 3 updates
2025-12-25 10:03:34 +01:00
Martin Matuška
c4597a73f3
Merge pull request #2815 from AZero13/=
Use >=, not =>
2025-12-25 10:00:35 +01:00
dependabot[bot]
79fac84eb2
CI: Bump the all-actions group across 1 directory with 3 updates
Bumps the all-actions group with 3 updates in the / directory: [actions/checkout](https://github.com/actions/checkout), [actions/upload-artifact](https://github.com/actions/upload-artifact) and [github/codeql-action](https://github.com/github/codeql-action).


Updates `actions/checkout` from 5.0.0 to 5.0.1
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](08c6903cd8...93cb6efe18)

Updates `actions/upload-artifact` from 4.6.2 to 5.0.0
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](ea165f8d65...330a01c490)

Updates `github/codeql-action` from 3.30.6 to 4.31.3
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](64d10c1313...014f16e7ab)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 5.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-actions
- dependency-name: actions/upload-artifact
  dependency-version: 5.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all-actions
- dependency-name: github/codeql-action
  dependency-version: 4.31.3
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-25 08:53:17 +00:00
Martin Matuška
8042630d4f
Merge pull request #2819 from GabrielBarrantes/work/typos
Improve wording
2025-12-25 09:48:17 +01:00
Martin Matuška
214ee3edc7
Merge pull request #2820 from skypher/oss-fuzz-expansion
Expand OSS-Fuzz integration: 1 → 25 fuzz targets
2025-12-25 09:47:17 +01:00
Leslie P. Polzer
eb6f992ba1 Refactor all fuzzers to use shared fuzz_helpers.h
Complete the refactoring of all 25 fuzzers:
- Remove duplicate Buffer struct definitions from 15 format fuzzers
- Remove duplicate DataConsumer class from 7 API fuzzers
- Update consume_bytes() calls to match new signature
- All fuzzers now use shared helpers from fuzz_helpers.h

This eliminates ~1000 lines of duplicated code.
2025-12-22 04:53:06 +00:00
Leslie P. Polzer
544b07541b Refactor fuzzers: add shared header, remove system() call
- Add fuzz_helpers.h with shared Buffer, reader_callback, DataConsumer
- Replace system("rm -rf") with nftw-based remove_directory_tree()
- Refactor entry, tar, write_disk fuzzers to use shared helpers
- Reduces code duplication and improves maintainability
2025-12-22 04:26:57 +00:00
Leslie P. Polzer
5e88593708 Expand OSS-Fuzz integration: 1 → 25 fuzz targets
Add comprehensive fuzzing coverage for libarchive:

Format-specific fuzzers (13):
- tar, zip, 7zip, rar, rar5, xar, cab, lha, iso9660, cpio, warc, mtree, ar

Security-critical fuzzers (4):
- encryption: encrypted archive handling
- write_disk: extraction path traversal
- read_disk: filesystem traversal, symlinks
- entry: ACL functions (previously 0% coverage)

API fuzzers (7):
- write: archive creation
- linkify: hardlink detection (complexity 775, was 0%)
- match: inclusion/exclusion patterns
- string: encoding conversions (UTF-8, wide chars)
- seek: seekable archive operations
- roundtrip: write-then-read consistency
- filter: compression/decompression

Supporting files:
- 14 dictionaries with format-specific magic bytes
- 9 options files for complex fuzzers
- Updated build script with seed corpora generation

Targets previously uncovered functions:
- archive_entry_linkify (complexity 775)
- ACL functions (complexity 705-713)
- xar_read_header (was 10.11% coverage)

Expected coverage improvement: 74% → 85-95%
2025-12-22 04:08:26 +00:00
Gabriel Barrantes
8f3fcf9ecd Improve wording 2025-12-21 17:30:42 -06:00
Tim Kientzle
6e77f521fa
Merge pull request #2812 from AZero13/w
Fix p == null copy paste error
2025-12-18 07:52:10 -08:00
AZero13
50a67c9223 Error check strdup for path name 2025-12-16 21:50:06 -05:00
AZero13
b39f91e5da Use >=, not => 2025-12-16 21:48:45 -05:00
AZero13
55fbf225c8 uname_override checks gname_override when it should check uname_override 2025-12-16 21:44:31 -05:00
AZero13
e75e5892fd We copy from p, not p + module_len 2025-12-16 21:41:05 -05:00
AZero13
784b778f3b Fix p == null copy paste error 2025-12-16 21:37:16 -05:00
Tim Kientzle
b51e59bcfb
Merge pull request #2807 from KlaraSystems/des/list-tests
Add option to list tests
2025-12-12 17:19:37 -08:00
Martin Matuška
a7f3b56af6
Merge pull request #2809 from mmatuska/fix/2787
tar: fix off-bounds read resulting from #2787 (3150539ed)
2025-12-12 12:04:09 +01:00
Martin Matuska
cfb02de558 tar: fix off-bounds read resulting from #2787 (3150539ed) 2025-12-09 22:40:42 +01:00
Dag-Erling Smørgrav
8295366f94 test_main: Add option to list tests
The test runner already lists available tests if it fails to parse the
command line, but add a -l option to explicitly do this without also
printing an error message and a summary of options.
2025-12-06 14:45:40 +01:00
Tim Kientzle
8c86c46d1b
Merge pull request #2805 from fredldotme/android-recovery
libarchive & contrib: Build as static binary for the Android recovery
2025-12-04 04:17:34 -08:00
Alfred Neumayer
752df6abb7 libarchive & contrib: Build as static binary for the Android recovery
Adds a 'bsdtar-recovery' Android build target for use in Android recoveries
as a static binary, and fixes some build failures on the get-go.

Tested on halium-7.1, halium-9.0 & halium-13.0.

Change-Id: I9b656e7016d4bf21517e2edb18f2a7733edc6982
2025-12-04 06:34:21 +01:00
Martin Matuška
728b43c0c1
Merge pull request #2800 from mmatuska/fix/freebsdci
CI: use gmake in Cirrus FreeBSD build
2025-12-01 13:31:22 +01:00
Martin Matuska
0a594ab77d CI: use gmake in Cirrus FreeBSD build 2025-11-28 22:31:25 +01:00
Martin Matuška
a819cc2829
Merge pull request #2797 from mmatuska/fix/treefuncs
Partially revert "Merge pull request #2679 from AZero13/error"
2025-11-28 00:57:09 +01:00
Tim Kientzle
1b9b42720f
Merge pull request #2799 from AZero13/idk
Prevent unneeded truncation
2025-11-26 21:08:01 -08:00
AZero13
827905c93f Prevent unneeded truncation
There is no reason we need to cast when every data type involved is size_t
2025-11-26 15:35:54 -05:00
Martin Matuska
aac59c1bd5 Partially revert "Merge pull request #2679 from AZero13/error"
This reverts commit d8aaf88c9feab047139df4cae60d845764a2480a, reversing
changes made to ee49ac81068f93754f004368f2cc72c95a8bf056.

tree_reopen() and tree_dup() return NULL only of they
are unable to allocate memory. Otherwise libarchive enters
ARCHIVE_FATAL if trying to walk an enterable but unreadable
directory.

__archive_ensure_cloexec_flag() operates only on fd >= 0
so there is no need to skip it

I have reimplemented the check around fdopendir()

Reported by:	Christian Weisgerber from OpenBSD
2025-11-24 14:16:53 +01:00
vcoxvco
f49372e945 libarchive/archive_util.c:__archive_issetugid: Fix uninitialized variable rgid 2025-11-23 19:27:42 +01:00
Tim Kientzle
8ef2084104
Merge pull request #2791 from KlaraSystems/des/383-fixes
Fix issues encountered while importing 3.8.3 downstream
2025-11-20 22:24:38 -08:00
Tim Kientzle
e17f169356
Merge pull request #2792 from KlaraSystems/des/generate-list
Generate test lists reliably and deterministically
2025-11-20 22:22:32 -08:00
Tim Kientzle
47809f10bf
Merge pull request #2793 from bgilbert/rar
Add missing rar5 test case to dist
2025-11-20 22:19:23 -08:00
Tim Kientzle
81bc00a549
Merge pull request #2787 from ljdarj/aar
Fix bsdtar zero-length pattern issue.
2025-11-20 21:40:17 -08:00
ARJANEN Loïc Jean David
3150539edb Fix bsdtar zero-length pattern issue.
Uses the sed-like way (and Java-like, and .Net-like, and Javascript-like…) to fix this issue of advancing the string to be processed by one if the match is zero-length.

Fixes libarchive/libarchive#2725 and solves libarchive/libarchive#2438.
2025-11-21 00:44:38 +01:00
Benjamin Gilbert
8f7d334646 Add missing rar5 test case to dist
Fixes: aafb078b7c ("Update 'archive_mstring_update_utf8' to attempt UTF8->WCS conversion on Windows if MBS conversion fails (#1978)")
2025-11-19 00:12:36 -08:00
Dag-Erling Smørgrav
12522911fa Fix low-hanging type issues 2025-11-19 01:18:18 +01:00
Dag-Erling Smørgrav
1890755ab2 Fix lseek argument order 2025-11-19 01:16:29 +01:00
Dag-Erling Smørgrav
35aac8a925 Fix the condition for using LIBXML_DOTTED_VERSION 2025-11-19 01:15:48 +01:00
Dag-Erling Smørgrav
fdec8c2f24 Improve test list generation
Update the lists of tests reliably and deterministically when the test sources change.
2025-11-19 01:12:50 +01:00
Dag-Erling Smørgrav
2df76f52c2 Clean up the top-level Makefile
Most of this is just moving headers out from *_SOURCES.
2025-11-19 01:05:41 +01:00
Martin Matuška
ce7b3f1c15
Merge pull request #2771 from mostynb/lz4_with_leading_skippable_frames
Support both lz4 and zstd data with leading skippable frames
2025-11-17 20:30:16 +01:00
Martin Matuška
dbacda991c
Merge pull request #2751 from KlaraSystems/des/zip_magic_numbers
Avoid magic numbers in zip support code
2025-11-17 20:27:46 +01:00
Martin Matuška
2caee6a37e
Merge pull request #2752 from KlaraSystems/des/safe-writes-umask
Set umask before testing safe writes
2025-11-17 20:26:35 +01:00
Martin Matuška
d5bd2dfafe
Merge pull request #2755 from mmatuska/fix/cirrusci
CI: update FreeBSD 14 build environment
2025-11-17 20:24:53 +01:00
Tim Kientzle
e1c3061b12
Merge pull request #2783 from YoshiRulz/docs-fix-typo
Fix typo in archive_entry_stat(3) man page
2025-11-16 16:18:03 -08:00
Tim Kientzle
c2333a511d
Merge pull request #2738 from cmcgee1024/add_clang_module_map
Add a clang module map for libarchive
2025-11-16 16:17:54 -08:00
YoshiRulz
d8fba4df3a
Fix typo in archive_entry_stat(3) man page 2025-11-13 12:46:23 +10:00
Chris McGee
f75b5ddab0
Provide a detailed description of the libarchive module map file 2025-11-12 08:42:03 -05:00
AZero13
02a76f2dc9 Remove unneeded int cast 2025-11-11 11:47:26 -05:00
Tim Kientzle
c5cc510145
Merge pull request #2778 from AZero13/result-0
Set *result to 0 when the tar flush fails.
2025-11-06 20:17:19 -08:00
Tim Kientzle
ab09af7304
Merge pull request #2654 from AZero13/swapping-2
s is a signed int, so make it signed int
2025-11-06 20:15:08 -08:00
Tim Kientzle
e929454ec8
Merge pull request #2779 from AZero13/descriptor
file_open should close if fstat fails
2025-11-06 20:13:10 -08:00
AZero13
3aa9c22ddf file_open should close if fstat fails 2025-11-06 11:14:45 -05:00
AZero13
daf5abf802 Add error handling 2025-11-06 10:46:27 -05:00
Rose
f18a754d02 s is a signed int, so make it signed int 2025-11-06 10:44:16 -05:00
AZero13
3396ba84d7 Set *result to 0 when the tar flush fails.
We should not uninitialize 0 when an error happens. Because t is then checked.
2025-11-06 10:02:41 -05:00
Tim Kientzle
26c769ecdc
Merge pull request #2775 from AZero13/off-by-one
[tar] Bounds check newdir_len
2025-11-04 19:30:01 -08:00
AZero13
45a873e998 Bounds check newdir_len
Honestly, this is of little consequence; if old_len is too big the program will crash anyway. However, an error exists just in case.
2025-11-04 19:02:08 -05:00
Tim Kientzle
fa5f70627c
Merge pull request #2769 from kientzle/kientzle-issue2765
Fix a buffer overrun when reading truncated 7zip headers
2025-11-02 14:17:48 -08:00
Tim Kientzle
c45a07854d
Merge pull request #2772 from moubctez/forget_name_max
Remove name_max leftover
2025-11-02 09:08:31 -08:00
Adam Ciarciński
f80b1ae294
Remove name_max leftover 2025-11-02 09:49:02 +01:00
Mostyn Bramley-Moore
1435c4b20c Skip over LZ4/zstd skippable frames when detecting data format
Since LZ4 and zstd share the same format for skippable frames, we need
to skip over these frames when trying to detect the format of compressed
data. Let's read up to something like 64kb of data when performing this
scanning.

Note that the LZ4 specification advises against starting with a skippable
frame, but doesn't forbid it:
> For the purpose of facilitating identification, it is discouraged to
> start a flow of concatenated frames with a skippable frame. If there
> is a need to start such a flow with some user data encapsulated into
> a skippable frame, it's recommended to start with a zero-byte LZ4
> frame followed by a skippable frame. This will make it easier for
> file type identifiers.

Resolves #2692.
2025-11-01 22:43:38 +01:00
Mostyn Bramley-Moore
989a303793 Test that we can read lz4 data with leading skippable frames
This is expected to fail until a followup commit, because lz4 and zstd
skippable frames are the same format and we don't skip over those when
performing format detection (yet).

Relates to #2692.
2025-11-01 22:23:21 +01:00
Tim Kientzle
f02961f402 Correct the new test expectations 2025-10-31 22:37:33 -07:00
Tim Kientzle
dc6c0c5f35 Fix a buffer overrun when reading truncated 7zip headers
This adjusts the request size for reading data from a 7zip SFX header
to ensure we get enough bytes to cover the following checks.

Resolves #2765
2025-10-31 22:31:45 -07:00
Tim Kientzle
ce614c6524
Merge pull request #2768 from Commandoss/master
Fix for an out-of-bounds buffer overrun when using p[H_LEVEL_OFFSET]
2025-10-31 22:07:19 -07:00
Tim Kientzle
8855146220
Merge pull request #2767 from KlaraSystems/des/posix_spawn
Replace system() with posix_spawn() if available
2025-10-31 07:27:15 -07:00
Tim Kientzle
edbada88c0
Merge pull request #2766 from mostynb/fix_mac_signed_unsigned_comparison
Fix signed-unsigned comparison in add_trivial_nfs4_acl
2025-10-31 07:23:44 -07:00
Илья
212426e751
heap-use-after-free(read) at src/libarchive/archive_read_support_format_lha.c:692:6 2025-10-31 15:23:55 +03:00
Mostyn Bramley-Moore
83c30ee813 Fix signed-unsigned comparison in add_trivial_nfs4_acl
Resolves #2760
2025-10-30 11:29:55 +01:00
Tim Kientzle
d2e861769c
Merge pull request #2753 from KlaraSystems/des/temp-files
Create temporary files in the target directory
2025-10-28 17:13:18 -07:00
Martin Matuska
89cbfe1028 CI: update FreeBSD 14 build environment 2025-10-15 23:41:46 +02:00
Dag-Erling Smørgrav
1c08abc60d Create temporary files in the target directory
Whenever we need to create a temporary file while writing to disk on a
POSIX system, try to create it in the same directory as the final file
instead of the current working directory.  The target directory can
reasonably be expected to be writable (and if it isn't, creating the
file will fail anyway), but the current working directory may not be.

While here, consistently use __archive_mkstemp(), and increase the
template from six to eight random characters.

Fixes:		2e73ea3a7db1 ("Fix max path-length metadata writing (#2243)")
Fixes:		e12c955dca63 ("Unify temporary directory handling")
2025-10-15 09:41:06 +02: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
d0f69b355d Add archive_string_dirname()
This function performs the equivalent of POSIX dirname(3) on a
struct archive_string.
2025-10-14 02:08:44 +02:00
Dag-Erling Smørgrav
7976476c9f Set umask before testing safe writes
Fixes:		27588eba5077 ("Fix replacing a regular file with a dir for ARCHIVE_EXTRACT_SAFE_WRITES")
2025-10-13 21:49:29 +02:00
Dag-Erling Smørgrav
51b3e14257 zip: Increase max size of Mac metadata
Raise the maximum size of Mac metadata from 4 MiB to 10 MiB, as that is
the value used by Apple themselves in the version of libarchive included
in Darwin.
2025-10-13 21:39:13 +02:00
Dag-Erling Smørgrav
33ac104169 zip: Avoid magic numbers
Provide preprocessor macros for two recurring magic numbers in the zip
support code: the length of the local file header (30 bytes) and the
maximum allowable size for Mac metadata (4 MiB).
2025-10-13 21:39:00 +02:00
Tim Kientzle
de73860cda
Merge pull request #2737 from kientzle/kientzle-volume-header-overflow
Fix an infinite loop when parsing `V` headers
2025-10-13 10:58:26 -07:00
Tim Kientzle
d207d816d0
Merge pull request #2749 from KlaraSystems/des/tempdir
Unify temporary directory handling
2025-10-13 10:57:18 -07:00
Dag-Erling Smørgrav
12cdd35f31 Drop unused variable.
Fixes:		a335429c5e71 ("Drop support for readdir_r()")
2025-10-13 16:58:44 +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
Martin Matuška
46fe318edd
Merge pull request #2722 from dependabot
CI: Bump the all-actions group across 1 directory with 3 updates
2025-10-11 22:12:11 +02:00
Tim Kientzle
582799ee57
Merge pull request #2746 from pbrisbin/patch-1
Fix invalid quoting in archive_entry_paths.3
2025-10-07 06:09:01 -07:00
dependabot[bot]
b12d1c14d1
CI: Bump the all-actions group across 1 directory with 3 updates
Bumps the all-actions group with 3 updates in the / directory: [actions/checkout](https://github.com/actions/checkout), [github/codeql-action](https://github.com/github/codeql-action) and [ossf/scorecard-action](https://github.com/ossf/scorecard-action).


Updates `actions/checkout` from 4.2.2 to 5.0.0
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](11bd71901b...08c6903cd8)

Updates `github/codeql-action` from 3.28.18 to 3.29.8
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](ff0a06e83c...76621b61de)

Updates `ossf/scorecard-action` from 2.4.1 to 2.4.2
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](f49aabe0b5...05b42c6244)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 5.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all-actions
- dependency-name: github/codeql-action
  dependency-version: 3.29.8
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: ossf/scorecard-action
  dependency-version: 2.4.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-06 16:07:23 +00:00
Pat Brisbin
6d8e1a883c
Fix invalid quoting in archive_entry_paths.3 2025-10-06 08:23:26 -04:00
Tim Kientzle
eb54a4d869 Add test case 2025-10-04 10:03:08 -07:00
Tim Kientzle
fda50c79ba
Merge pull request #2740 from dunhor/gnutar_longpath_unicode
Check WCS pathname in header_gnutar before overwriting
2025-10-03 20:43:21 -07:00
Tim Kientzle
372e709c1a
Merge pull request #2729 from KlaraSystems/des/leak-on-fatal
Don't leak memory on fatal error
2025-09-27 10:25:03 -07:00
Tim Kientzle
4ecf62fbd7
Merge pull request #2742 from bradking/parse-date-2038
parse_date: handle dates in 2038 and beyond if time_t is big enough
2025-09-26 19:52:20 -07:00
Tim Kientzle
c34ff01c02
Merge pull request #2741 from e-kwsm/extra-semi
fix: remove extra ';' outside of functions
2025-09-26 19:50:52 -07:00
Brad King
2d987e725f parse_date: handle dates in 2038 and beyond if time_t is big enough 2025-09-26 17:48:56 -04:00
Eisuke Kawashima
7fdf32b6b2
fix: remove extra ';' outside of functions 2025-09-26 19:41:30 +09:00
Duncan Horn
98731ad500 Check WCS pathname in header_gnutar 2025-09-25 16:03:18 -07:00
Tim Kientzle
be31ad37f3
Merge pull request #2739 from DHowett/remove-wincrypt
windows: remove support for WinCrypt
2025-09-24 06:21:23 -07: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
Chris McGee
52bf0d7de0
Add a clang module map for libarchive
When compiling libarchive using clang in module mode a special
module.modulemap file describes the structure of the header files
so that they can be imported modularly. Having this file makes
it easier for modular uses of the library out of the box so that
clients don't need to write their own, potentially making errors
in doing so.

Add a module.modulemap in the public header file location so that
clang and related tools can find it easily.
2025-09-22 11:11:02 -04:00
Tim Kientzle
36a530973a Fix an infinite loop when parsing V headers
Our tar header parsing tracks a count of bytes that need to be
consumed from the input.  After each header, we skip this many bytes,
discard them, and reset the count to zero.  The `V` header parsing
added the size of the `V` entry body to this count, but failed to
check whether that size was negative.  A negative size (from
overflowing the 64-bit signed number parsing) would decrement this
count, potentially leading us to consume zero bytes and leading to an
infinite loop parsing the same header over and over.

There are two fixes here:
* Check for a negative size for the `V` body
* Check for errors when skipping the bytes that
  need to be consumed

Thanks to Zhang Tianyi from Wuhan University for finding
and reporting this issue.
2025-09-16 08:25:57 -07:00
Tim Kientzle
39dc43b3e0
Merge pull request #2734 from kientzle/kientzle-ignore-too-long-gzip-filename
Ignore over-long gzip filename
2025-09-13 19:34:03 -07:00
Tim Kientzle
638464b477 Fix the reference to the archive object 2025-09-13 13:07:33 -07:00
Martin Matuška
ab5cb61f49
Merge pull request #2735 from kientzle/kientzle-err.h-conflict
Rename err.h to avoid conflict with system header
2025-09-13 22:01:52 +02:00
Martin Matuška
38debf6be1
Merge pull request #2731 from mmatuska/fix/macosci
CI: add workaround for cmake installed from local/pinned tab on GH/MacOS
2025-09-13 21:36:29 +02:00
Martin Matuška
e1dea559c7
Merge pull request #2732 from mmatuska/fix/safe-dir-over-reg-win
win: add complementary safe writes fix for Windows to 27588eba5 (#2477)
2025-09-13 21:36:13 +02:00
Tim Kientzle
96f76577d3 Rename err.h to avoid conflict with system header
Depending on header search path ordering, we can easily
confuse libarchive_fe/err.h with the system header.
Rename ours to lafe_err.h to avoid the confusion.
Rename libarchive_fe/err.c to match.
2025-09-13 12:30:03 -07:00
Tim Kientzle
e5c2eb783b Only set the filename-present bit if we actually write the filename 2025-09-13 11:17:38 -07:00
Tim Kientzle
a3787a34a8 Fix some nearby formatting 2025-09-12 09:03:01 -07:00
Tim Kientzle
a2933fbefd Ignore overlong gzip original_filename
We reuse the compression buffer to format the gzip header,
but didn't check for an overlong gzip original_filename.
This adds that check.  If the original_filename is
over 32k (or bigger than the buffer in case someone shrinks
the buffer someday), we WARN and ignore the filename.
2025-09-12 09:01:13 -07:00
Martin Matuska
123d92bc3a win: add complementary safe writes fix for Windows to 27588eba5 (#2477) 2025-09-10 10:59:40 +02:00
Martin Matuska
ff3a0c37aa CI: add workaround for cmake installed from local/pinned tab on GH/MacOS 2025-09-10 10:50:46 +02:00
Martin Matuška
589659ed7f
Merge pull request #2670 from benoit-pierre/pr/fix_zip_writing_with_zstd_compression_method
zip: fix writing with ZSTD compression
2025-09-10 10:41:33 +02:00
Martin Matuška
52db141ece
Merge pull request #2477 from jrtc27/safe-dir-over-reg
Fix replacing a regular file with a dir for ARCHIVE_EXTRACT_SAFE_WRITES
2025-09-10 10:40:44 +02:00
Martin Matuška
3b1100f9a9
Merge pull request #2686 from stoeckmann/lseek_win_regression
Fix Windows off_t handling
2025-09-10 10:24:34 +02:00
Martin Matuška
6bd863f612
Merge pull request #2710 from meecash/CVE-2025-25724-check_strftime_result
Fix CVE-2025-25724 by checking the result of the strftime
2025-09-10 10:22:58 +02:00
Dag-Erling Smørgrav
4768f38535 archive_write: Set archive state to fatal if format or filters fail
In archive_write_header(), if the format method or a filter flush method
fails, we set the archive state to fatal, but we did not do this in
archive_write_data() or archive_write_finish_entry().  There is no good
reason for this discrepancy.  Not setting the archive state to fatal
means a subsequent archive_write_free() will invoke archive_write_close()
which may retry the operation and cause archive_write_free() to return
an unexpected ARCHIVE_FATAL.
2025-09-08 23:33:32 +02:00
Dag-Erling Smørgrav
3a072e0bb0 write_add_filter_bzip2: End compression in the freer
If a fatal error occurs, the closer will not be called, so neither will
BZ2_bzCompressEnd(), and we will leak memory.  Fix this by calling it a
second time from the freer.  This is harmless in the non-error case as
it will see that the compression state has already been cleared and
immediately return BZ_PARAM_ERROR, which we simply ignore.
2025-09-08 23:33:32 +02:00
Dag-Erling Smørgrav
06191cd287 archive_write_client: Free state in freer, not in closer
The closer will not be called if a fatal error occurs, so the current
arrangement results in a memory leak.  The downside is that the freer
may be called even if we were not fully constructed, so it needs to
perform additional checks.  On the other hand, knowing that the freer
always gets called and will free the client state simplifies error
handling in the opener.
2025-09-08 23:15:57 +02:00
Tim Kientzle
53135ca48e
Merge pull request #2717 from peakschris/cb_windows
bsdtar: Allow @filename to have CRLF endings
2025-08-22 08:13:40 -07:00
Chris Brown
37ab51c2d3 address review comment 2025-08-22 04:00:44 -04: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
François Degros
f12d80442c Use sysconf(_SC_OPEN_MAX) on systems without close_range or closefrom
Close all the file descriptors in the range [3 ..
sysconf(_SC_OPEN_MAX)-1] before executing a filter program to avoid
leaking file descriptors into subprocesses.

Bug: https://github.com/libarchive/libarchive/issues/2520
2025-08-20 15:47:18 +10:00
Tim Kientzle
892f331450
Merge pull request #2696 from al3xtjames/mkstemp
Fix mkstemp path in setup_mac_metadata
2025-08-16 10:27:11 -06:00
Martin Matuška
bf50fe0538
Merge pull request #2723 from KlaraSystems/des/couldnt-visit
archive_read_disk_posix: Don't pass -1 to a function expecting errno
2025-08-14 23:22:30 +02:00
Martin Matuška
2db13f7422
Merge pull request #2716 from antekone/bug/GH-2714/infinite-loop/1
RAR5 reader: early fail when file declares data for a dir entry
2025-08-14 23:20:55 +02:00
Martin Matuška
93f9e93d73
Merge pull request #2713 from antekone/bug/GH-2711/crash-when-rr/1
RAR5 reader: fix multiple issues in extra field parsing function
2025-08-14 23:20:01 +02:00
Martin Matuška
12ffcef28c
Merge pull request #2700 from mostynb/avoid_libxml2_deprecation_warnings
xar: avoid libxml2 deprecation warnings
2025-08-14 23:17:39 +02:00
Dag-Erling Smørgrav
02ebfb5a48 archive_read_disk_posix: Don't pass -1 to a function expecting errno
This fixes an unhelpful "Couldn't visit directory: Unknown error: -1" message.

Fixes:		3311bb52cbe4 ("Bring the code supporting directory traversals from bsdtar/tree.[ch] into archive_read_disk.c and modify it. Introduce new APIs archive_read_disk_open and archive_read_disk_descend.")
2025-08-14 15:29:34 +02:00
Chris Brown
e099b418e3 revert test verbosity change 2025-08-09 16:43:55 -04:00
Chris Brown
6a008e524e revert ci fix which didn't help 2025-08-09 16:13:26 -04:00
Chris Brown
835fe1133f disable tests on windows; they don't work 2025-08-09 15:51:48 -04:00
Chris Brown
466a2b5c7b fix test 2025-08-09 15:50:45 -04:00
Chris Brown
640c9feced fix mingw windows build issue 2025-08-09 15:32:55 -04:00
Chris Brown
9e7af6f21c increase test verbosity 2025-08-09 15:28:34 -04:00
Chris Brown
652a0c107b enable tests on windows 2025-08-09 15:08:49 -04:00
Chris Brown
980b541632 update autotools 2025-08-08 20:53:33 -04:00
Chris Brown
8b3d3ee99b update test 2025-08-08 20:40:14 -04:00
Chris Brown
fb859e6d3f add test 2025-08-08 20:15:35 -04:00
Chris Brown
da65b39c06 suggested changes by kientzle 2025-08-08 19:41:51 -04:00
Chris Brown
e47c315f51 debug non-printing characters and handle CRLF 2025-08-08 11:56:39 -04:00
Grzegorz Antoniak
cb403667d7 RAR5 reader: early fail when file declares data for a dir entry
RAR5 reader had inconsistent sanity checks for directory entries that
declare data. On one hand such declaration was accepted during the
header parsing process, but at the same time this was disallowed during
the data reading process. Disallow logic was returning the
ARCHIVE_FAILED error code that allowed the client to retry, while in
reality, the error was non-retryable.

This commit adds another sanity check during the header parsing logic
that disallows the directory entries to declare any data. This will make
clients fail early when such entry is detected.

Also, the commit changes the ARCHIVE_FAILED error code to ARCHIVE_FATAL
when trying to read data for the directory entry that declares data.
This makes sure that tools like bsdtar won't attempt to retry unpacking
such data.

Fixes issue #2714.
2025-08-04 19:52:53 +02:00
Grzegorz Antoniak
0ff100c8d3 RAR5 reader: fix multiple issues in extra field parsing function
This commit fixes multiple issues found in the function that parses
extra fields found in the "file"/"service" blocks.

1. In case the file declares just one extra field, which is an
   unsupported field, the function returns ARCHIVE_FATAL.

   The commit fixes this so this case is allowed, and the unsupported
   extra field is skipped. The commit also introduces a test for this
   case.

2. Current parsing method of extra fields can report parsing errors in
   case the file is malformed. The problem is that next iteration of
   parsing, which is meant to process the next extra field (if any),
   overwrites the result of the previous iteration, even if previous
   iteration has reported parsing error. A successful parse can be
   returned in this case, leading to undefined behavior.

   This commit changes the behavior to fail the parsing function early.
   Also a test file is introduced for this case.

3. In case the file declares only the EX_CRYPT extra field, current
   function simply returns ARCHIVE_FATAL, preventing the caller from
   setting the proper error string. This results in libarchive returning
   an ARCHIVE_FATAL without any error messages set. The PR #2096 (commit
   adee36b00) was specifically created to provide error strings in case
   EX_CRYPT attribute was encountered, but current behavior contradicts
   this case.

   The commit changes the behavior so that ARCHIVE_OK is returned by the
   extra field parsing function in only EX_CRYPT is encountered, so that
   the caller header reading function can properly return ARCHIVE_FATAL
   to the caller, at the same time setting a proper error string. A test
   file is also provided for this case.

This PR should fix issue #2711.
2025-08-03 15:28:58 +02:00
Tim Kientzle
3bf1035e67
Merge pull request #2712 from KlaraSystems/des/readdir_r
Drop support for readdir_r()
2025-08-02 16:33:01 -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
23ee781520 Use POSIX_SPAWN_CLOEXEC_DEFAULT when possible
Use posix_spawn() with POSIX_SPAWN_CLOEXEC_DEFAULT on systems that
define this constant, in order to avoid leaking file descriptors into
subprocesses.

Bug: https://github.com/libarchive/libarchive/issues/2520
2025-07-31 15:56:31 +10: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
Marcin Mikula
ecce46744f Fix CVE-2025-25724 by checking the result of the strftime
to avoid use of undefined content of buf, in case when custom
locale makes the result string longer than buf length.

Signed-off-by: Marcin Mikula <marcin@helix.pl>
2025-07-30 10:33:51 +02:00
Tim Kientzle
6062470cbc
Merge pull request #2704 from kientzle/kientzle-harden-append-acl
Guard against invalid type arguments
2025-07-26 12:24:43 -07:00
Tim Kientzle
aa1fc90ae5 Guard against invalid type arguments
Some experiments showed strange things happen if you
provide an invalid type value when appending a new ACL entry.
Guard against that, and while we're here be a little more
paranoid elsewhere against bad types in case there is another
way to get them in.
2025-07-26 11:10:24 -07:00
Benoit Pierre
d1418af239 zip: fix writing with ZSTD compression
When testing the feature with `bsdtar -acf test.zip --options
zip:compression=zstd …` on a tree of ~100MB, the execution would
appear to "hang" while writing a multi-gigabytes ZIP file.
2025-07-21 11:35:27 +02:00
Tim Kientzle
cc97338239
Merge pull request #2699 from mostynb/7z_eopm_reference
7z: add liblzma EOPM reference
2025-07-17 19:18:53 -07:00
Mostyn Bramley-Moore
ed2ada78a6 7z: add liblzma EOPM reference
This is useful for developers trying to understand the 7z read support code.
2025-07-15 22:13:10 +02:00
Mostyn Bramley-Moore
4dfaf2d359 xar: avoid libxml2 deprecation warnings 2025-07-15 13:18:14 +02:00
Tim Kientzle
cb6b9e9a28
Merge pull request #2697 from Kraust/topic/cmake_build_fixes
Allow Compiling Against Static CRT.
2025-07-14 10:05:56 -07:00
Kraust
d2d72ac78a Allow Compiling Against Static CRT. 2025-07-13 22:57:25 -04:00
Alex James
b57d14f9c9
Fix mkstemp path in setup_mac_metadata
setup_mac_metadata currently concates the template after TMPDIR without
adding a path separator, which causes mkstemp to create a temporary file
next to TMPDIR instead of in TMPDIR. Add a path separator to the
template to ensure that the temporary file is created under TMPDIR.

I hit this while rebuilding libarchive in nixpkgs. Lix recently started
using a dedicated build directory (under /nix/var/nix/builds) instead of
using a directory under /tmp [1]. nixpkgs & Lix support (optional)
on macOS sandboxing. The default sandbox profile allows builds to access
paths under the build directory and any path under /tmp. Because the
build directory is no longer under /tmp, some of libarchive's tests
started to fail as they accessed paths next to (but not under) the build
directory:

cpio/test/test_basic.c:65: Contents don't match
   Description: Expected: 2 blocks
, options=
  file="pack.err"
0000_62_73_64_63_70_69_6f_3a_20_43_6f_75_6c_64_20_6e_bsdcpio: Could n
0010_6f_74_20_6f_70_65_6e_20_65_78_74_65_6e_64_65_64_ot open extended
0020_20_61_74_74_72_69_62_75_74_65_20_66_69_6c_65_0a_ attribute file.

Sandbox: bsdcpio(11215) deny(1) file-write-create /nix/var/nix/builds/nix-build-libarchive-3.8.0.drv-7tar.md.5EUrQu

[1]: https://lix.systems/blog/2025-06-24-lix-cves/
2025-07-12 15:44:55 -05:00
Tim Kientzle
267042ebc7
Merge pull request #2694 from stoeckmann/cleanups
Perform various cleanups
2025-07-11 21:06:20 -07:00
Tobias Stoeckmann
a3d261a29a rar: Fix typos in comments
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-07-09 23:13:51 +02:00
Tobias Stoeckmann
3c646995db archive_read: Fix formatting
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-07-09 23:13:51 +02:00
Tobias Stoeckmann
7b59a6b693 SECURITY.md: Turn singular into plural
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-07-09 23:13:51 +02:00
Tobias Stoeckmann
e559754d6d mtree: Fix grammar and typos
Fix grammar and typos in comments and error messages.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-07-09 23:13:48 +02:00
Tobias Stoeckmann
82e247fe7c archive_string: Use correct data types
If it's already known that we use variables for calculations with
size_t, use size_t for them directly instead of int, even if values
fit.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-07-09 23:06:09 +02:00
Tobias Stoeckmann
eff524fa4e Fix formatting in archive_string_sprintf.c
Do not mix tabs and spaces if not needed.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-07-09 22:58:38 +02:00
Tobias Stoeckmann
84e8f3c98e tar: Remove unneeded casts
The variable size is already of type size_t. No need to cast it again
to size_t.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-07-09 22:57:40 +02:00
Tobias Stoeckmann
4035fca93a Define ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto to 1
All other define statements set a value. Set one here as well for
maximum compatibility.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-07-09 22:55:12 +02:00
Tobias Stoeckmann
3997a5f28a Do not truncate seek requests
If a seek cannot be fulfilled, fail directly with EOVERFLOW to match
regular lseek behavior.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-29 21:35:44 +02:00
Tobias Stoeckmann
d01dc496d3 Fix Windows off_t handling
The off_t datatype in Windows is 32 bit, which leads to issues when
handling files larger than 2 GB.

Add a wrapper around fstat/stat calls to return a struct which has a
properly sized st_size variable. On systems with an off_t representing
the actual system limits, use the native system calls.

This also fixes mtree's checkfs option with large files on Windows.

Fixes https://github.com/libarchive/libarchive/issues/2685
Fixes 89b8c35ff4b5addc08a85bf5df02b407f8af1f6c

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-29 21:35:39 +02:00
Tim Kientzle
d06700a098
Merge pull request #2691 from kientzle/kientzle-issue2681
Add missing test file
2025-06-29 12:03:51 -07:00
Tim Kientzle
2db02ae6ae Add missing test file 2025-06-28 20:45:14 -07:00
Tim Kientzle
595fb29e4c
Merge pull request #2664 from fedegiova/fix_leak_for_cb_error
Fix a memory leak if write callback error early
2025-06-28 19:15:32 -07:00
Tim Kientzle
609d8122f1
Merge pull request #2658 from stoeckmann/skip_tests
Skip tests if respective support is missing
2025-06-28 19:14:17 -07:00
Tim Kientzle
31cff981e4
Merge pull request #2673 from 004helix/master
archive_cryptor_private.h: check message digest functions are enabled for windows
2025-06-28 19:10:27 -07:00
Tim Kientzle
d8aaf88c9f
Merge pull request #2679 from AZero13/error
Handle possible errors from system calls
2025-06-28 19:09:12 -07:00
Tim Kientzle
ee49ac8106
Merge pull request #2687 from hemant-jadhav-emerson/master
Supress restrict keyword for msc_ver older than 1927
2025-06-28 19:04:30 -07:00
Tim Kientzle
9fe18ba0a6
Merge pull request #2689 from ElvishJerricco/linux-fs-flags
clear_nochange_fflags: Use linux FS flags
2025-06-28 14:23:02 -07:00
Tim Kientzle
cd020d1ccb
Merge pull request #2684 from DHowett/dev/duhowett/shim_open
win32: shim wopen, and make both open/wopen use _s "secure" variant
2025-06-28 14:22:26 -07:00
Tim Kientzle
a474bab7e3
Merge pull request #2688 from stoeckmann/entry_off32
Ignore sizes which do not fit into off_t
2025-06-28 14:11:17 -07:00
Will Fancher
489d0b8e2f clear_nochange_fflags: Use linux FS flags 2025-06-27 19:24:34 -04:00
Tobias Stoeckmann
1e4b84ed30 Ignore sizes which do not fit into off_t
It is possible to handle entries and files with sizes which do not fit
into off_t of the current system (Windows always has 32 bit off_t and
32 bit systems without large file support also have 32 bit off_t).

Set sizes to 0 in such cases. The fstat system call would return -1 and
set errno to EOVERFLOW, but that's not how archive_entry_set_size acts.
It would simply ignore negative values and set the size to 0.

Actual callers of archive_entry_stat from foreign projects seem to not
even check for NULL return values, so let's try to handle such cases as
nice as possible.

Affects mtree's checkfs option as well (Windows only, 32 bit systems
would simply fail in fstat/stat).

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-27 17:06:14 +02:00
Dustin Howett
50d44b4202 win32: shim wopen, and make both open/wopen use _s "secure" variant
The new `__la_wopen` wrapper is a copy of `__la_open` that
expects--rather than converts--a wcs parameter.

The `sopen` variants are offered as "more secure" variants of `open` and
`wopen`; I cannot vouch for their security, but some build systems are
strict about the use of "banned insecure APIs".

I've confirmed that `_wsopen_s` and `_open_s` are present in the Windows
Vista SDK.

I did not confirm that they are available in the Windows XP Platform
SDK, in part because in e61afbd463d1 (2016!) Tim says:

> I'd like to completely remove support for WinXP and earlier.
2025-06-26 10:56:33 -07:00
Rose
b1b3709cae Handle possible errors from system calls
dup, open, etc, can fail and we should not assume they do not.
2025-06-20 17:35:54 -04:00
Tim Kientzle
ffde04f272
Merge pull request #2672 from AZero13/ferror
Fix error checking in writing files
2025-06-20 14:33:45 -07:00
Rose
fd4ecc0146 Fix error checking in writing files
For write, 0 may not mean an error at all. We need to instead check for the length not being the same.

With fwrite, because 0 could mean an error, but not always. We must check that we wrote the entire file!

Note that unlike write, fwrite's description according to POSIX does not mention returning a negative type at all. Nor does it say you can retry unlike write.

Finally, with write, we need to check less than 0, not 0, as 0 is a valid return and does not mean an error.
2025-06-20 13:55:57 -04:00
Tim Kientzle
a218a52dbb
Merge pull request #2678 from mostynb/zstd_filter_checksum
Enable Zstandard's checksum feature in the zstd write filter
2025-06-20 09:32:51 -07:00
Mostyn Bramley-Moore
0de62cbda8 Enable Zstandard's checksum feature in the zstd write filter
Note that this is not enabled when writing .zip or .7z archive formats,
because they already use their own checksums.

Implements #2675.
2025-06-20 14:42:40 +02:00
Tim Kientzle
e4978e2edd
Merge pull request #2677 from AZero13/fwrite
Change error message from "fwrite function failed" to "write function failed"
2025-06-19 16:12:26 -07:00
Rose
40a89c7379 Change error message from "fwrite function failed" to "write function failed"
We are checking the return value from write, not fwrite, so this message is wrong.
2025-06-19 14:44:43 -04:00
Tim Kientzle
6a252c84a2
Merge pull request #2676 from danyeaw/fix-pkgconf-path
Fix .pc location when CMAKE_INSTALL_LIBDIR not set
2025-06-19 08:20:43 -07:00
Dan Yeaw
4984c652db Fix .pc location when CMAKE_INSTALL_LIBDIR not set 2025-06-18 21:27:04 -04:00
Hemant
664a20b6c7 Error related to restrict keyword supressed for older vs compiler 2025-06-18 14:05:23 -05:00
Hemant
b7066d4a6b Error related to restrict keyword supressed for older vs compiler 2025-06-18 13:51:00 -05:00
Martin Matuška
6effe2ec6b
Merge pull request #2659 from stoeckmann/chld
Improve filter process handling
2025-06-12 10:59:43 +02:00
Martin Matuška
251f7e839c
Merge pull request #2669 from benoit-pierre/pr/minor_test_related_tweaks
minor test related tweaks
2025-06-12 10:57:17 +02:00
Martin Matuška
47bdf82489
Merge pull request #2663 from stoeckmann/filename_errpath
open_filename: Free memory on error paths
2025-06-12 10:56:32 +02:00
Martin Matuška
c3be70e071
Merge pull request #2665 from stoeckmann/read_data_sparse
archive_read_data: Handle sparse holes at end of file correctly
2025-06-12 10:54:08 +02:00
Martin Matuška
9bdc5b82f7
Merge pull request #2668 from stoeckmann/7z_oob
7zip: Fix out of boundary access
2025-06-12 10:51:45 +02:00
Raman Shyshniou
475423a154 archive_cryptor_private.h: check message digest functions are enabled for windows 2025-06-12 00:22:47 +00:00
Benoit Pierre
864c904442 test_utils: factorize canProg implementations 2025-06-08 00:05:58 +02:00
Benoit Pierre
dcf5475661 test_utils: fix canRunCommand implementation
Do not unconditionally cache the result of the first call (and
reused it for subsequent calls). Thankfully, the function is
only called once.
2025-06-08 00:05:34 +02:00
Tobias Stoeckmann
90c1e32a0d open_filename: Free memory on error paths
If opening a filename fails, make sure that allocated memory which is
not inserted into any remaining structure is freed.

Fixes https://github.com/libarchive/libarchive/issues/1949

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-05 22:17:56 +02:00
Tobias Stoeckmann
c0691458a0 7zip: Fix out ouf boundary read in ELF detection
Make sure that the string table size is not smaller than 6 (and also
not larger than SIZE_MAX for better 32 bit support).

Such small values would lead to a large loop limit which either leads to
a crash or wrong detection of a ".data" string in possibly uninitialized
memory.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-05 21:38:43 +02:00
Tobias Stoeckmann
75ef803092 7zip: Increase minimum ELF header length
The 64 bit format requires at least 63 bytes, so increase this limit.
Such small binaries most likely don't contain 7zip data anyway.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-05 21:36:23 +02:00
Tim Kientzle
0931c12b7e
Merge pull request #2662 from stoeckmann/set_format_strcpy
archive_read_set_format: Remove strcpy calls
2025-06-04 05:58:32 -07:00
Tobias Stoeckmann
b1839a20e5 archive_read: Handle sparse holes at end of file
If a sparse hole is located at the end of an entry, then the tar
parser returns ARCHIVE_EOF while updating the offset where 0 bytes of
data will follow.

If archive_read_data encounters such an ARCHIVE_EOF return value, it
has to recheck if the offsets (data offset and output offset) still
match. If they do not match, it has to keep filling 0 bytes.

This changes assumes that it's okay to call archive_read_data_block
again after an EOF. As far as I understood the parsers so far, this
should be okay, since it's always ARCHIVE_EOF afterwards.

Fixes https://github.com/libarchive/libarchive/issues/1194

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-03 22:01:15 +02:00
Tobias Stoeckmann
f3949062ed rar: Do not forcefully set offset to unpacked size
If an entry reaches its end of file, the offset is not necessarily
the same as unp_size. This is especially true for links which have
a "0 size body" even though the unpacked size is not 0.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-03 21:59:05 +02:00
Tobias Stoeckmann
cdb45d71b2 warc: Ignore separator when reaching end of entry
When _warc_read encounters end of entry, it adds 4 bytes to the last
offset for \r\n\r\n separator, which is never written. Ignore these
bytes since they are not part of the returned entry.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-03 21:57:42 +02:00
Tobias Stoeckmann
fa85c7eaae xar: End with entry offset, not archive offset
If xar_read_data has no further data, set offset to end of entry,
not to total size of parsed archive so far.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-03 21:57:05 +02:00
Federico Giovanardi
aa69d34311 Fix a memory leak if write callback error early 2025-06-03 18:24:35 +02:00
Tobias Stoeckmann
5a60d8cda4 archive_read_set_format: Remove strcpy calls
The string constants can be used directly for comparison, which makes
this code robust against future changes which could lead to names being
longer than str could hold on stack.

Also removes around 100 bytes from compiled library (with gcc 15).

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-03 17:43:27 +02:00
Tobias Stoeckmann
ac66e0bc42 Skip zlib tests if support is missing
If zlib is not supported, do not run tests to avoid false positives.

Also adjust tests to support latest gzip versions (1.10+) which store
less information for improved reproducibility. The gzip binary is
used as a fallback if zlib is not available.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-03 17:27:48 +02:00
Tobias Stoeckmann
f2c3c790ff Skip lzma test if support is missing
If lzma is not supported, do not run tests to avoid false positives.

Fixes https://github.com/libarchive/libarchive/issues/2647

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-03 17:27:48 +02:00
Tobias Stoeckmann
b7e1c617cb Skip KOI8 conversion test if support is missing
If a unix system has no iconv support, the best effort function will
be unable to convert KOI8 to UTF-8. Skip the test if such support is
missing.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-03 17:27:48 +02:00
Tobias Stoeckmann
c40a3887ab unzip: Pass test if encryption support is missing
If no encryption support exists, the -P option will always fail.
"Skip" the test by making sure that there really is no encryption
support according to libarchive functions.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-03 17:27:48 +02:00
Tobias Stoeckmann
9836e7e2fe zip: Better detect no encryption support
Some functions might return -1 in case of library error. Use an
own return value if a stub function was used for better error
messages.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-03 17:27:48 +02:00
Tim Kientzle
a8f93f2480
Merge pull request #2660 from kevans91/ke/fix-fortify
libarchive/test: fix build when memcpy() is a macro
2025-06-03 06:02:09 -07:00
Kyle Evans
b76c4042ae libarchive/test: fix build when memcpy() is a macro
After importing the latest libarchive into FreeBSD, Shawn Webb @
HardenedBSD noted that the test build is broken when FORTIFY_SOURCE=2
while building the base system.  Braced initializer lists are a special
case that need some extra fun parentheses when we're dealing with the
preprocessor.

While it's not a particularly common setup, the extra parentheses don't
really hurt readability all that much so it's worth fixing for wider
compatibility.

Fixes: libarchive/libarchive#2657
2025-06-02 21:46:28 -05:00
Tobias Stoeckmann
36bac92cd2 tools: Enforce default handling of SIGCHLD
Ignoring SIGCHLD gets passed to child processes. Doing that has
influence on waitpid, namely that zombie processes won't be
created. This means that a status can never be read.

We can't enforce this in library, but libarchive's tools can be
protected against this by enforcing default handling.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-02 23:29:49 +02:00
Tobias Stoeckmann
2764062e65 Unify reader and writer filter process handling
Use pid_t since waitpid returns a pid_t. Also check for a negative
return value in writer as well to avoid reading the possibly
unitialized status value.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-02 23:28:26 +02:00
Tobias Stoeckmann
13700e1fb8 windows: close child process handle only once
Calling CloseHandle multiple times for the same handle can lead to
exceptions while debugging according to documentation.

Mimic the waitpid handling for success cases to behave more like the
Unix version which would "reap the zombie".

Doing this for an unsuccessful call is off, but the loop is never
entered again, so I guess it's okay and worth it to reduce the amount
of Windows specific definitions in source files.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-02 23:23:05 +02:00
Tobias Stoeckmann
d7d1d19bb6 windows: Preserve GetExitCodeProcess error
If the waitpid version for Windows fails, preserve the error code and
avoid overwriting it with a possible CloseHandle error.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-02 23:21:26 +02:00
Tim Kientzle
0f9a06d6ab
Merge pull request #2655 from mmatuska/fix/setclocale
test_utils/test_main.c: satisfy -Wstrict-prototypes
2025-06-01 16:04:49 -07:00
Martin Matuska
1311a438a3 test_utils/test_main.c: satisfy -Wstrict-prototypes 2025-06-01 23:35:05 +02:00
Martin Matuška
70978468e9
Merge pull request #2627 from heirecka/do-not-hard-code-pkg-config
Use PKG_CONFIG instead of hard-coded pkg-config
2025-05-31 21:40:04 +02:00
Martin Matuška
c7b7bd7c0e
Merge pull request #2643 from stoeckmann/tar_pax_sparse
tar: Handle extra bytes after sparse entries
2025-05-31 21:31:14 +02:00
Tim Kientzle
8d074302ac
Merge pull request #2652 from stoeckmann/wstring_ensure
Check archive_wstring_ensure return value
2025-05-31 07:16:07 -07:00
Tobias Stoeckmann
e1ca935c00 Always check archive_wstring_ensure return value
Memory allocation might fail, so check if it was successful.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-31 11:37:02 +02:00
Tobias Stoeckmann
e1c0f9a660 write disk windows: Release memory on error paths
Free wsp in case of out of memory condition.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-31 11:31:50 +02:00
Tobias Stoeckmann
20b4a4cb7c iso9660: Check another archive_string_ensure result
Missed one unchecked archive_string_ensure in the previous commit.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-31 09:46:17 +02:00
Tim Kientzle
101230094c
Merge pull request #2651 from stoeckmann/string_ensure_check
Always check archive_string_ensure return value
2025-05-30 19:50:25 -07:00
Tim Kientzle
8540cb7cfb
Merge pull request #2648 from stoeckmann/test_en_us
test_utils: Enforce C locale for all tests
2025-05-30 19:35:44 -07:00
Tim Kientzle
e2eda9e68b
Merge pull request #2650 from stoeckmann/string_sort
archive_utility_string_sort: Use qsort directly
2025-05-30 19:33:34 -07:00
Tobias Stoeckmann
9ac39a0168 Always check archive_string_ensure return value
Memory allocation might fail, so check if it was successful.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-30 23:42:40 +02:00
Tobias Stoeckmann
0a320b6a37 Remove archive_utility_string_sort with 4.0.0
The archive_utility_string_sort function won't be part of the 4.0.0 API
anymore. No users were found and such a task should be done outside of
the library.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-30 17:41:26 +02:00
Tobias Stoeckmann
f90d036057 archive_utility_string_sort: Use qsort directly
The utility function "archive_utility_string_sort" is a custom qsort
implementation. Since qsort is specified in C11 and POSIX.1-2008
which libarchive is based on, use system's qsort directly.

The function is not used directly in libarchive, so this is a good
way to save around 500 bytes in resulting library without breaking
compatibility for any user of this function (none found).

Also allows more than UINT_MAX entries which previously were limited
by data type and (way earlier) due to recursion.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-30 17:41:12 +02:00
Tobias Stoeckmann
65d0393f24 test_list_item: Do not modify LC_TIME
Test cases already get a C locale, which is sufficient for this test.
IF LC_TIME was not previously set, the used en_US.UTF-8 would stay
as an environment variable, possibly affecting other test cases.
Since en_US.UTF-8 is not guaranteed to be available, C is a better
choice.

Fixes https://github.com/libarchive/libarchive/issues/2560

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-30 17:33:19 +02:00
Tobias Stoeckmann
e70e24a738 test_utils: Reset all locale related entries
Reset current locale settings through setlocale and also all
environment variables which might affect test cases which
spawn children through systemf which in turn would call setlocale
on their own, e.g. bsdtar.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-30 17:32:02 +02:00
Tim Kientzle
9b07a143ee
Merge pull request #2634 from stoeckmann/tar_neg_time
tar: Support negative time values with pax
2025-05-29 17:31:28 -07:00
Tim Kientzle
cd5c44c5d0
Merge pull request #2649 from stoeckmann/compress_recursion
compress: Prevent call stack overflow
2025-05-29 16:37:44 -07:00
Tobias Stoeckmann
2ed2db55e8 compress: Prevent call stack overflow
Explicitly use goto to turn a recursive call into an iterative one.
Most compilers do this on their own with default settings, but MSVC
with default settings would create a binary which actually performs
recursive calls.

Fixes call stack overflow in binaries compiled with low optimization.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-29 15:07:02 +02:00
Tim Kientzle
59b09796c3
Merge pull request #2642 from stoeckmann/seek_regress
Fix FILE_skip regression
2025-05-27 20:55:15 -07:00
Tim Kientzle
d261f46ae5
Merge pull request #2644 from stoeckmann/tar_neg_size
tar: Always treat negative sizes as error
2025-05-27 20:52:36 -07:00
Tim Kientzle
dcdd7338d6
Merge pull request #2645 from stoeckmann/tar_formatter
tar: Fix archive_set_error formatters
2025-05-27 20:43:46 -07:00
Tim Kientzle
702f31a01c
Merge pull request #2646 from stoeckmann/sparse32
tar: Handle many sparse comments on 32 bit systems
2025-05-27 20:41:19 -07:00
Tobias Stoeckmann
ebca997192 tar: Handle many sparse comments on 32 bit systems
The sparse 1.0 parser skips lines with comments. The amount of skipped
bytes is stored in a ssize_t variable, although common 32 bit systems
allow files larger than 4 GB.

Gracefully handle files with more than 2 GB bytes full of comments to
prevent integer truncations.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-27 21:30:19 +02:00
Tobias Stoeckmann
9d07162b08 tar: Fix archive_set_error formatters
Use correct formatters and casts with newly introduced ll
length modifier.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-27 20:50:53 +02:00
Tobias Stoeckmann
33d3528723 tar: Always treat negative sizes as error
If a pax global header specifies a negative size, it is possible to
reduce variable `unconsumed` by 512 bytes, leading to a re-reading
of the pax global header. Fortunately the loop verifies that only one
global header per entry is allowed, leading to a later ARCHIVE_FATAL.

Avoid any form of negative size handling and fail early.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-27 20:46:51 +02:00
Tobias Stoeckmann
715f7eac02 tar: Handle extra bytes after sparse entries
Skip all entry bytes after sparse entries were encountered. This matches
GNU tar behavior.

I have adjusted (and fixed) the existing test case for this. The test
case test_read_format_gtar_sparse_skip_entry did not work with GNU tar.

In #2558 it was explained that the pax size always overrides the header
size (correct). Since the pax size in the test case was way larger than
the actual entry bytes in archive, GNU tar choke on the test file.

The libarchive parser did not skip any bytes not already read due to
references by sparse entries, so the huge pax size was not detected.

By adjusting the test case to have a leftover byte (only 3 bytes are
referenced through sparse entry now, leaving one extra byte) with a
correct pax size and an invalid header size (after all it is overridden
by pax size), GNU tar works and libarchive gets off its 512 byte
alignment, not being able to read the next entry.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-27 19:57:05 +02:00
Tobias Stoeckmann
51b4c35bb3 Fix FILE_skip regression
The fseek* family of functions return 0 on success, not the new offset.
This is only true for lseek.

Fixes https://github.com/libarchive/libarchive/issues/2641
Fixes dcbf1e0ededa95849f098d154a25876ed5754bcf

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-27 17:09:12 +02:00
Tim Kientzle
6389d172ed
Merge pull request #2640 from robUx4/xml-uuid
[cmake] add uuid library when using xmllite
2025-05-26 09:06:47 -07:00
Steve Lhomme
ac96967e36 [cmake] add uuid library when using xmllite
Consecutive to 16fd043f51d911b106f2a7834ad8f08f65051977
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
Tim Kientzle
341dd5d1d4
Merge pull request #2637 from stoeckmann/pax_nl
tar: Keep block alignment after pax error
2025-05-25 16:22:59 -07:00
Tim Kientzle
18d456377e
Merge pull request #2639 from stoeckmann/sprintf_ll
Add ll length modifier to archive_string_vsprintf
2025-05-25 16:19:38 -07:00
Tobias Stoeckmann
bc5f0884e3 Add ll length modifier to archive_string_vsprintf
Some error messages already use the ll length modifier, which results
in raw formatter output, i.e. "%lld" instead of a number.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-25 14:27:46 +02:00
Tobias Stoeckmann
101646e34e tar: Keep block alignment after pax error
If a pax attribute has a 0 length value and no newline, the tar reader
gets out of sync with block alignment.

This happens because the pax parser assumes that variable value_length
(which includes the terminating newline) is at least 1. To get the
real value length, 1 is subtracted. This result is subtracted from
extsize, which in this case would lead to `extsize -= -1`, i.e.
the remaining byte count is increased.

Such an unexpected calculation leads to an off-by-one when skipping
to the next block. In supplied test case, bsdtar complains that the
checksum of the next block is wrong. Since the tar parser was not
properly 512 bytes aligned, this is no surprise.

Gracefully handle such a case like GNU tar does and warn the user that
an invalid attribute has been encountered.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-25 12:03:55 +02:00
Tim Kientzle
b6e1f06457
Merge pull request #2636 from zhaofengli/reset-header-state-after-mac-metadata
tar: Reset accumulated header state after reading macOS metadata blob
2025-05-24 17:18:00 -07:00
Zhaofeng Li
0685c77e83 Add test for macOS metadata reading in tar archives
Signed-off-by: Zhaofeng Li <hello@zhaofeng.li>
2025-05-24 16:42:26 -06:00
Zhaofeng Li
5bb36db5e1 tar: Reset accumulated header state after reading macOS metadata blob
AppleDouble extension entries are present as separate files immediately
preceding the corresponding real files. In libarchive, we process the
entire metadata file (headers + data) as if it were a header in the real
file. However, the code forgets to reset the accumulated header state
before parsing the real file's headers. In one code path, this causes
the metadata file's name to be used as the real file's name.

Specifically, this can be triggered with a tar containing two files:

1. A file named `._badname` with pax header containing the `path` attribute
2. A file named `goodname` _with_ a pax header but _without_ the `path` attribute

libarchive will list one file, `._badname` containing the data of `goodname`.

This code is pretty brittle and we really should let the client deal with
it :(

Fixes #2510.

Signed-off-by: Zhaofeng Li <hello@zhaofeng.li>
2025-05-24 14:33:08 -06:00
Tim Kientzle
42c2f84649
Merge pull request #2630 from stoeckmann/wincrypt_casts
Fix archive_wincrypt_version
2025-05-24 10:45:57 -07:00
Tim Kientzle
6dbea2df3b
Merge pull request #2633 from stoeckmann/match_cleanup
archive_match: Simplify and clean up code
2025-05-24 10:37:02 -07:00
Tobias Stoeckmann
a5d9c9a7cd tar: Support negative time values with pax
Pax extended headers may specify negative time values for files older
than the epoch.

Adjust the code to clear values to 0.0 more often and set ps to
INT64_MIN to have a proper error specifier, because the parser does
not allow anything below -INT64_MAX.

Fixes https://github.com/libarchive/libarchive/issues/2562

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-24 19:28:22 +02:00
Tim Kientzle
cdc185e917
Merge pull request #2632 from stoeckmann/cygwin_definition
Prefer __CYGWIN__ over CYGWIN definition
2025-05-24 10:23:28 -07:00
Tobias Stoeckmann
8b978a0368 archive_match: Fix whitespaces, style
Adjust whitespaces to match file layout and add a full stop to
a comment to match others.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-24 12:37:44 +02:00
Tobias Stoeckmann
bef52da622 archive_match: Use correct data type for iterator
Iterating over a size_t with unsigned could lead to an endless loop
while adding uid/gid to a list which already counts 4 billion
entries.

I doubt that this can ever happen, given that the routines become
very slow with insertions, but better be safe than sorry.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-24 12:35:32 +02:00
Tobias Stoeckmann
8b763d872c archive_match: Allow arbitrarily long match lists
Turn unmatched_count into a size_t to support as many entries as
possible on the machine.

If more than INT_MAX entries are not matched, truncate the result
of archive_match_path_unmatched_inclusions for external callers.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-24 12:28:08 +02:00
Tobias Stoeckmann
51e66d32c6 archive_match: Remove unneeded count fields
The count fields are merely used to check if a list is empty or not.
A check for first being not NULL is sufficient and is already in
place while iterating over the linked elements (count is not used).

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-24 12:24:49 +02:00
Tobias Stoeckmann
4223b4c548 archive_match: Set red/black tree operations once
The operations for key and node comparison depend on the platform
libarchive is compiled for. Since these values do not change
during runtime, set them only once during initialisation.

Further simplify the code by declaring only one "rb_ops" with
required functions based on platform.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-24 12:10:49 +02:00
Tobias Stoeckmann
612223356e Prefer __CYGWIN__ over CYGWIN definition
The cygwin FAQ states that __CYGWIN__ is defined when building for a
Cygwin environment. Only a few test files check (inconsistently) for
CYGWIN, so adjust them to the recommended __CYGWIN__ definition.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-24 11:37:26 +02:00
Tim Kientzle
0ed4435209
Merge pull request #2631 from stoeckmann/configure_windows
configure.ac: Improve Windows version detection
2025-05-23 19:58:02 -07:00
Tim Kientzle
992734d6cc
Merge pull request #2509 from tesap/install-lib-dir
Make installation lib dir depend on CMAKE_INSTALL_LIBDIR variable
2025-05-23 19:57:14 -07:00
Tim Kientzle
627ba5bbbf
Merge pull request #2629 from mmatuska/fix/versiontest
tests: accept underscore in arbitrary third-party version strings
2025-05-23 19:39:00 -07:00
Tobias Stoeckmann
2cdf47f332 Set ARCHIVE_CRYPTOR_USE_WINCRYPT for WinCrypt
If WinCrypt is used, actually set ARCHIVE_CRYPTOR_USE_WINCRYPT
for version details output.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-23 19:43:26 +02:00
Tobias Stoeckmann
d8ff8dd62c archive_version_details.c: Drop ARCHIVE_DIGEST_*
These definitions are never available and are supposedly a leftover of
a work in progress.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-23 19:43:24 +02:00
Tobias Stoeckmann
d6f6fdf979 configure.ac: Improve Windows version detection
Include windows.h for better windows version detection.

Fixes https://github.com/libarchive/libarchive/issues/2628

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-23 19:22:41 +02:00
Tobias Stoeckmann
38ac49553d Fix archive_wincrypt_version compilation
Cast address of "version" to BYTE pointer for CryptGetProvParam.
Fix "major" variable assignment for picky compilers like MSVC.

The "length" variable is an in/out variable. It must be set to the size
of available memory within "version". Right now it is undefined behavior
and 0 would crash during runtime.

Fixes https://github.com/libarchive/libarchive/issues/2628

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-23 19:05:21 +02:00
Martin Matuska
9eacf09a86 tests: accept underscore in arbitrary third-party version strings
Fixes #2626
2025-05-23 13:20:25 +02:00
Heiko Becker
0ddaa5f71c Use PKG_CONFIG instead of hard-coded pkg-config 2025-05-21 00:44:50 +02:00
Tim Kientzle
2961b132d0
Merge pull request #2624 from mmatuska/feat/390dev
Libarchive 3.9.0dev
2025-05-20 07:55:26 -07:00
Martin Matuska
182726d16a Libarchive 3.9.0dev 2025-05-20 10:29:10 +02:00
dependabot[bot]
714e357b97
CI: Bump the all-actions group across 1 directory with 4 updates (#2623)
Bumps the all-actions group with 4 updates:
`actions/checkout` from 4.2.1 to 4.2.2
`actions/upload-artifact` from 4.4.3 to 4.6.2
`github/codeql-action` from 3.26.12 to 3.28.18
`ossf/scorecard-action` from 2.4.0 to 2.4.1
2025-05-20 10:19:56 +02:00
Mostyn Bramley-Moore
d80d734190
Add some more error checking to shell scripts (#2617)
Exit immediately if a command exits with a non-zero status, and treat
unset variables as an error when substituting.
2025-05-20 10:14:17 +02:00
Tim Kientzle
352b710754
Merge pull request #2612 from AZero13/okay-what
Fatal if field[0].start is null
2025-05-19 19:39:10 -07:00
Tim Kientzle
6976a252aa
Merge pull request #2622 from AZero13/calculate-size
Calculate size of arrays instead of assuming they are always 6
2025-05-19 19:38:04 -07:00
Tim Kientzle
a4f0571fb6
Merge pull request #2621 from AZero13/redundant-s
*s != '\0' is redundant
2025-05-19 19:36:57 -07:00
Tim Kientzle
b921c8673b
Merge pull request #2619 from AZero13/patch-2
days should be a long type
2025-05-19 19:34:24 -07:00
Tim Kientzle
2c1ee4d2b1
Merge pull request #2618 from AZero13/patch-1
Label error and errorx as __LA_NORETURN
2025-05-19 19:32:32 -07:00
Rose
9f4c179c3f Calculate size of arrays instead of assuming they are always 6 2025-05-19 15:22:56 -04:00
Rose
fd2130b970 *s != '\0' is redundant
Not that this does anything to codegen probably, but it is still redundant.
2025-05-19 15:16:18 -04:00
Rose
bde1c16393 Fatal if field[0].start or field[0].end is null
We should not get here, but given that the check exists, we should not let it happen if this is NULL because otherwise we just dereference it later on.
2025-05-19 14:35:45 -04:00
AZero13
b1348fbfab
days should be a long type
The difference in years is cast to a long and then multiplied by 365. The return value of the function is also a long.
2025-05-19 13:39:32 -04:00
AZero13
cfc1f3a9da
Label error and errorx as __LA_NORETURN
This also prevents clang-tidy from reporting some false bugs.
2025-05-19 13:35:19 -04:00
Tim Kientzle
17a63c7e35
Merge pull request #2611 from zhaofengli/fix-iconv-pc
autotools: Fix iconv issues in generated .pc file
2025-05-18 15:44:48 -07:00
Tim Kientzle
51793de834
Merge pull request #2613 from mmatuska/fix/7zipsfx-2
7z: fix another out-of-bounds read in 7z SFX archive detection
2025-05-18 15:41:26 -07:00
Tim Kientzle
23f414385e
Merge pull request #2616 from mostynb/contrib_psota-benchmark_tcp_sh_bash
contrib/psota-benchmark/tcp.sh is a bash script
2025-05-18 15:26:17 -07:00
Tim Kientzle
0a4e506f3e
Merge pull request #2614 from AZero13/tar-2
Assign a result when failure happens
2025-05-18 15:25:11 -07:00
Tim Kientzle
3b4bf62fbd
Merge pull request #2600 from nvinson/master
Copy ae digests to mtree_entry
2025-05-18 14:59:36 -07:00
Mostyn Bramley-Moore
fe41cec3da
Remove long-unused travis CI script (#2615)
Support for travis CI was removed in 2019, this script hasn't been used
since.
2025-05-18 18:55:32 +02:00
Mostyn Bramley-Moore
ead8cd69bd contrib/psota-benchmark/tcp.sh is a bash script
I am unsure if this is still used, but it fails to run in Bourne shell.
2025-05-18 12:58:31 +02:00
Rose
5c61984652 Assign a result when failure happens
In some places, result is checked even after failure, so let's assign a result.
2025-05-17 21:24:51 -04:00
Martin Matuska
3128f04f58 7z: fix another out-of-bounds read in 7z SFX archive detection
When looping over program header entries (e_shnum)
we need to increment sec_tbl_offset by e_shentsize
and not by fixed values.

Fixes OSS-Fuzz issue 418349489
2025-05-18 03:07:49 +02:00
Tim Kientzle
fbd168bd2a
Merge pull request #2610 from stoeckmann/string_int_size_t
archive_string: Check values before casts
2025-05-17 17:15:03 -07:00
Zhaofeng Li
6b2c5e0ba4 autotools: Fix iconv issues in generated .pc file
The goal is to make everyone (including msys2) happy.

Fixes #1766 and #1819.

Signed-off-by: Zhaofeng Li <hello@zhaofeng.li>
2025-05-17 13:50:16 -06:00
Tim Kientzle
fc4964751f
Merge pull request #2609 from stoeckmann/safe_fprintf
tar: Handle more edge cases in safe_fprintf
2025-05-17 11:46:32 -07:00
Nicholas Vinson
6dd27bc4a3
test_utils/test_main.c: increase logfilename bf sz
Increase logfilename buffer size from 64 to 256. This aligns the buffer
size with the size limits found in Windows and Linux.
2025-05-17 11:45:20 -04:00
Nicholas Vinson
0e88bc1ecc
Replace struct ae_mset_digest with uint_least32_t
Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
2025-05-17 11:33:15 -04:00
Nicholas Vinson
ea49bb3057
Copy ae digests to mtree_entry
Copy ae digests to mtree_entry. This simplifies porting non-archive
    formats to archive formats while preserving supported message
    digests specifically in cases where recomputing digests is not
    viable.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
2025-05-17 11:33:15 -04:00
Tobias Stoeckmann
7b0c8a62cc archive_string: Check values before casts
The size_t to int conversion is especially required on Windows systems
to support their int-based functions. These variables should be properly
checked before casts. This avoids integer truncations with large
strings.

I prefer size_t over int for sizes and adjusted variables to size_t
where possible to avoid casts.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-17 10:42:51 +02:00
Tim Kientzle
981fd9afed
Merge pull request #2604 from mmatuska/fix/7zipsfx
7z: fix out-of-bounds read in 7z self extracting archive detection
2025-05-16 16:40:24 -07:00
Tim Kientzle
1b9c075735
Merge pull request #2607 from zhaofengli/disallow-multiple-files-from
bsdtar: Disallow multiple --files-from/-T options
2025-05-16 15:49:16 -07:00
Tobias Stoeckmann
c2d06848ea tar: Make safe_fprintf more platform independent
If vsnprintf fails with errno EOVERFLOW, the results are very platform
dependent but never useful. The implementation in glibc fills bytes with
blanks, FreeBSD fills them with zeros, OpenBSD and Windows set first
byte to '\0'.

Just stop processing and don't print anything, which makes it follow
the OpenBSD and Windows approach.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-17 00:23:01 +02:00
Tobias Stoeckmann
f3f2aaf0ac tar: Fix safe_fprintf comment
The stack buffer is never used for out of memory messages.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-17 00:23:01 +02:00
Tobias Stoeckmann
d1a260932c tar: Support large strings in safe_fprintf
The vsnprintf calls might return INT_MAX with very long strings.
Prevent a signed integer overflow when taking an additional nul
byte into account.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-17 00:23:00 +02:00
Tobias Stoeckmann
0e15b864c1 tar: Always use correct length in safe_fprintf
If the format buffer shall not be further increased in size, the
length value mistakenly takes the terminating nul byte into account.

This is in contrast to a successful vsnprintf call.

Also use the correct string length if fallback to stack buffer is
required.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-17 00:22:15 +02:00
Tobias Stoeckmann
3f1e45d146 tar: Clear safe_fprintf stack before usage
The stack buffer is never cleared, which can become an issue depending
on vsnprintf implementation's behavior if -1 is returned. The code
would eventually fall back to stack buffer which might be not
nul terminated.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-16 23:50:27 +02:00
AZero13
c7203f805d
7z: Free the file if compression-level option is invalid (#2608)
Otherwise, the file is leaked.
2025-05-16 23:41:18 +02:00
Zhaofeng Li
00d559e4b9 bsdtar: Disallow multiple --files-from/-T options 2025-05-16 11:35:36 -06:00
Tim Kientzle
428167e750
Merge pull request #2606 from zhaofengli/parse-unix-epoch-date
Support @-prefixed Unix epoch timestamps as date strings
2025-05-15 18:06:03 -07:00
Zhaofeng Li
6b97a57e8e Support @-prefixed Unix epoch timestamps as date strings
Signed-off-by: Zhaofeng Li <hello@zhaofeng.li>
2025-05-15 09:59:33 -06:00
Zhaofeng Li
c26f037745
bsdtar: Support --mtime and --clamp-mtime (#2601)
Hi,

This PR adds support for setting a forced mtime on all written files
(`--mtime` and `--clamp-mtime`) in bsdtar.

The end goal will be to support all functionalities in
<https://reproducible-builds.org/docs/archives/#full-example>, namely
`--sort` and disabling other attributes (atime, ctime, etc.).

Fixes #971.

## History

- [v1](https://github.com/zhaofengli/libarchive/tree/forced-mtime-v1):
Added `archive_read_disk_set_forced_mtime` in libarchive. As a result,
it was only applied when reading from the filesystem and not from other
archives.
- [v2](https://github.com/zhaofengli/libarchive/tree/forced-mtime-v2):
Refactored to apply the forced mtime in `archive_write`.
- v3 (current): Reduced libarchive change to exposing
`archive_parse_date`, moved clamping logic into bsdtar.

---------

Signed-off-by: Zhaofeng Li <hello@zhaofeng.li>
Co-authored-by: Dustin L. Howett <dustin@howett.net>
2025-05-15 14:08:14 +02:00
Marcus Tillmanns
84ac71335f
Allow setting the original filename for gzip compressed files (#2544)
Co-authored-by: Martin Matuška <martin@matuska.de>
2025-05-15 14:07:48 +02:00
Moroshima
293c8bb992
correct only modes of --no-mac-metadata in bsdtar.1 (#2597)
`--no-mac-metadata` is c, r, u and x mode only
2025-05-15 12:59:37 +02:00
James Hilliard
63d7c24eea
Fix mbedtls version 3 compatibility (#2602)
We need to use the new API for mbedtls 3 compatibility

Fixes #2025

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2025-05-15 12:56:59 +02:00
AZero13
b50b8a42f6
safe_printf should annotate with restrict (#2605)
printf has restrict for its parameters, and safe_printf should do the
same.
2025-05-14 18:24:54 -07:00
Martin Matuska
1667b31d0b 7z: fix out-of-bounds read in 7z self extracting archive detection
Fixes OSS-Fuzz issue 416832167
2025-05-14 16:18:19 +02:00
Tobias Stoeckmann
a612bf62f8
rar: Fix heap-buffer-overflow (#2599)
A filter block size must not be larger than the lzss window, which is
defined
by dictionary size, which in turn can be derived from unpacked file
size.

While at it, improve error messages and fix lzss window wrap around
logic.

Fixes https://github.com/libarchive/libarchive/issues/2565

---------

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Co-authored-by: Tim Kientzle <kientzle@acm.org>
2025-05-11 19:00:11 +02:00
Tobias Stoeckmann
09685126fc
rar: Fix double free with over 4 billion nodes (#2598)
If a system is capable of handling 4 billion nodes in memory, a double
free could occur because of an unsigned integer overflow leading to a
realloc call with size argument of 0. Eventually, the client will
release that memory again, triggering a double free.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-10 17:17:19 -07:00
mehrabiworkmail
c8dc3bcb47
7z sfx overaly detection (#2088)
To detect 7z SFX files, libarchive currently searches for the 7z header
in a hard-coded addr range of the PE/ELF file
(specified via macros SFX_MIN_ADDR and SFX_MAX_ADDR). This causes it to
miss SFX files that may stray outside these values (libarchive fails to
extract 7z SFX ELF files created by recent versions of 7z tool because
of this issue). This patch fixes the issue by finding a more robust
starting point for the 7z header search: overlay in PE or the .data
section in ELF. This patch also adds 3 new test cases for 7z SFX to
libarchive.

Fixes https://github.com/libarchive/libarchive/issues/2075

---------

Co-authored-by: Masoud Mehrabi Koushki <masoud.mehrabi.koushki1@huawei.com>
Co-authored-by: Martin Matuška <martin@matuska.de>
2025-05-09 19:21:32 +02:00
Mostyn Bramley-Moore
5d2a788e41
7zip reader: add test for POWERPC filter support for LZMA compressor (#2460)
This new test archive contains a C hello world executable built like so
on a ubuntu 24.04 machine:
```
int main(int argc, char *argv[]) {
  printf("hello, world\n");
  return 0;
}
```

`powerpc-linux-gnu-gcc hw.c -o hw-powerpc -Wall`

The test archive that contains this executable was created like so,
using 7-Zip 24.08: `7zz a -t7z -m0=lzma2 -mf=ppc
libarchive/test/test_read_format_7zip_lzma2_powerpc.7z hw-powerpc`

The new test archive is required because the powerpc filter for lzma is
implemented in liblzma rather than in libarchive.
2025-05-09 13:40:56 +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 e619342dfa36b887ffa0ea33e98d04cb161cd7de
Closes #1811
2025-05-09 13:40:21 +02:00
Tim Kientzle
1ba83d4b3f
Polish for GNU tar format reading/writing (#2455)
A few small tweaks to improve reading/writing of the legacy GNU tar
format.

* Be more tolerant of redundant 'K' and 'L' headers
* Fill in missing error messages for redundant headers
* New test for reading archive with redundant 'L' headers
* Earlier identification of GNU tar format in some cases

These changes were inspired by Issue #2434. Although that was determined
to not technically be a bug in libarchive, it's relatively easy for
libarchive to tolerate duplicate 'K' and 'L' headers and we should be
issuing appropriate error messages in any case.
2025-05-09 13:36:05 +02:00
Tobias Stoeckmann
1d7eadf417
Fix archive_time.c issues (concurrency, 32 bit) (#2563)
The refactoring of https://github.com/libarchive/libarchive/pull/2553
introduced three issues:

1. Introduction of a modifiable global static variable

This violates the goal of having no global variables as stated in [the
README.md](b6f6557abb/README.md (L195))
which in turn leads to concurrency issues. Without any form of mutex
protection, multiple threads are not guaranteed to see the correct
min/max values. Since these are not needed in regular use cases but only
in edge cases, handle them in functions with local variables only.

Also the global variables are locale-dependent which can change during
runtime. In that case, future calls leads to issues.

2. Broken 32 bit support

The writers for zip and others affected by the previously mentioned PR
and test-suite on Debian 12 i686 are broken, because the calculation of
maximum MS-DOS time is not possible with a 32 bit time_t. Treat these
cases properly.

3. Edge case protection

Huge or tiny int64_t values can easily lead to unsigned integer
overflows. While these do not affect stability of libarchive, the
results are still wrong, i.e. are not capped at min/max as expected.

In total, the functions are much closer to their original versions again
(+ more range checks).

---------

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-09 13:33:32 +02:00
Tobias Stoeckmann
3e4683f5c4
rar: Check packed_size constraints (#2591)
Make sure that size_t casts do not truncate the value of packed_size on
32 bit systems since it's 64 bit. Extensions to RAR format allow 64 bit
values to be specified in archives.

Also verify that 64 bit signed arithmetics do not overflow.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-09 13:31:24 +02:00
Tobias Stoeckmann
2b8db0f82d
rar: Fix rar_read_ahead call stack overflow (#2592)
It is possible to trigger a call stack overflow by repeatedly entering
the rar_read_ahead function. In normal circumstances, this recursion is
optimized away by common compilers, but default settings with MSVC keep
the recursion in place. Explicitly turn the recursion into a goto-loop
to avoid the overflow even with no compiler optimizations.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-09 13:31:00 +02:00
Tobias Stoeckmann
4f4e0e4b70
rar: Clean up br on split archive entries (#2593)
Reset avail_in and next_in if the next entry of a split archive is
parsed to always update its internal structure to access next bytes when
cache runs empty.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-09 13:30:32 +02:00
Tobias Stoeckmann
e744746cc1
rar: Support large headers on 32 bit systems (#2596)
Support header sizes larger than 32 bit even on 32 bit systems, since
these normally have large file support. Otherwise an unsigned integer
overflow could occur, leading to erroneous parsing on these systems.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-09 13:29:53 +02:00
Tobias Stoeckmann
761e2f3c1e
Unify spacing in archive_read_support_format_rar.c (#2590)
Most source files use tabs instead of spaces, but
archive_read_support_format_rar.c uses spaces most of the time. A few
lines contain a mixture of tabs and spaces, which leads to poorly
formatted output with many default settings.

Unify the style. No functional change and preparation for upcoming
changes to get rid of white space diffs.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-04-27 16:22:34 -07:00
Tim Kientzle
966010ce79
Improve support for AFIO 64-bit inode values (#2589)
PR #2258 hardened AFIO parsing by converting all inode values >= 2^63 to
zero values. This turns out to be problematic for filesystems that use
very large inode values; it results in all such files being viewed as
hardlinks to each other.

PR #2587 partially addressed this by instead considering inode values >=
2^63 as invalid and just ignoring them. This prevented the accidental
hardlinking, but at the cost of losing all hardlinks that involved large
inode values.

This PR further improves things by stripping the high order bit from
64-bit inode values in the AFIO parser. This allows them to be mostly
preserved and should allow hardlinks to get properly processed in the
vast majority of cases. The only false hardlinks would be when there are
inode values that differ exactly in the high order bit, which should be
very rare.

A full solution will require expanding inode handling to use unsigned
64-bit values; we can't do that without a major version bump, but this
PR also sets the stage for migrating inode support in a future
libarchive 4.0.
2025-04-26 16:10:45 -07:00
Brian Campbell
7c02cde37a
Fix overflow in build_ustar_entry (#2588)
The calculations for the suffix and prefix can increment the endpoint
for a trailing slash. Hence the limits used should be one lower than the
maximum number of bytes.

Without this patch, when this happens for both the prefix and the
suffix, we end up with 156 + 100 bytes, and the write of the null at the
end will overflow the 256 byte buffer. This can be reproduced by running
```
mkdir -p foo/bar
bsdtar cvf test.tar foo////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////bar
```
when bsdtar is compiled with Address Sanitiser, although I originally
noticed this by accident with a genuine filename on a CHERI capability
system, which faults immediately on the buffer overflow.
2025-04-25 21:11:19 -07:00
Dmitry Ivankov
be8d08868c
bsdtar: don't hardlink negative inode files together (#2587)
It seems that valid inode can be 64-bit and negative (or rather outside
of 64-bit signed range)


a60615d5be/sys/sys/_types.h (L124)
7e74f756f5/include/linux/types.h (L22)

But signed type is used in libarchive and there were some fuzzing issues
with it, https://github.com/libarchive/libarchive/pull/2258 converts
negative `ino` to `0`, which is actually a reserved inode value, but
more importantly it was still setting `AE_SET_INO` flag and later on
hardlink detection will treat all `0` on same `dev` as hardlinks to each
other if they have some hardlinks.

This showed up in BuildBarn FUSE filesystem
https://github.com/buildbarn/bb-remote-execution/issues/162 which has
both
- setting number of links to a big value
- generating random inode values in full uint64 range

Which in turn triggers false-positive hardlink detection in `bsdtar`
with high probability.

Let's mitigate it
- don't set `AE_SET_INO` on negative values (assuming rest of code isn't
ready to correctly handle full uint64 range)
- check that `ino + dev` are set in link resolver
2025-04-22 07:29:44 -07:00
Tobias Stoeckmann
dcbf1e0ede
Do not skip past EOF while reading (#2584)
Make sure to not skip past end of file for better error messages. One
such example is now visible with rar testsuite. You can see the
difference already by an actually not useless use of cat:

```
$ cat .../test_read_format_rar_ppmd_use_after_free.rar | bsdtar -t
bsdtar: Archive entry has empty or unreadable filename ... skipping.
bsdtar: Archive entry has empty or unreadable filename ... skipping.
bsdtar: Truncated input file (needed 119 bytes, only 0 available)
bsdtar: Error exit delayed from previous errors.
```

compared to

```
$ bsdtar -tf .../test_read_format_rar_ppmd_use_after_free.rar
bsdtar: Archive entry has empty or unreadable filename ... skipping.
bsdtar: Archive entry has empty or unreadable filename ... skipping.
bsdtar: Error exit delayed from previous errors.
```

Since the former cannot lseek, the error is a different one
(ARCHIVE_FATAL vs ARCHIVE_EOF). The piped version states explicitly that
truncation occurred, while the latter states EOF because the skip past
the end of file was successful.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-04-14 21:02:17 -07:00
Graham Percival
f96497248e
bsdtar: start "fake short equivalents" enum higher (#2586)
This avoids possible conflict with command-line options such as -B.
2025-04-14 11:39:14 -07:00
zhongfly
948a52d672
archive_version_details: add missing ';' at end of declaration (#2585)
Close #2579
2025-04-14 07:37:38 -07:00
Tobias Stoeckmann
e1c8c9ef64
tar: Improve LFS support on 32 bit systems (#2582)
The size_t data type is only 32 bit on 32 bit sytems while off_t is
generally 64 bit to support files larger than 2 GB.

If an entry is declared to be larger than 4 GB and the entry shall be
skipped, then 32 bit systems truncate the requested amount of bytes.
This leads to different interpretation of data in tar files compared to
64 bit systems.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-04-13 11:07:18 -07:00
Graham Percival
8f49a18f64
Avoid some casts by changing the private API (#2578) 2025-04-12 13:58:03 -07:00
Graham Percival
992a596290
Fix missing newline at EOF (#2577) 2025-04-11 20:10:04 -07:00
AZero13
da6bc7bf27
i should be size_t (#2575)
The size of i does not matter, and a size_t is added to it, so to avoid
that truncation, just make i size_t. It also is passed as a size_t.
2025-04-10 20:14:55 -07:00
Lukas Javorsky
95c386317f
Remove unnecessary sharutils dependency (#2571)
Resolves issue: #2570
2025-04-08 20:23:27 -07:00
ARJANEN Loïc Jean David
4c0b3618a4
Fixes Windows compile issue (#2538)
Solves a Windows compile issue when OpenSSH/mbedTLS/Nettle is activated
and on the build system's paths by making the Windows API backend higher
priority on Windows (meaning that only RIPEMD160 will use
OpenSSH/mbedTLS/Nettle anymore).

Fixes #2536 and starts on #2320.
2025-04-07 08:04:27 -07:00
Tobias Stoeckmann
ef09372952
warc: Prevent signed integer overflow (#2568)
If a warc archive claims to have more than INT64_MAX - 4 content bytes,
the inevitable failure to skip all these bytes could lead to parsing
data which should be ignored instead.

The test case contains a conversation entry with that many bytes and if
the entry is not properly skipped, the warc implementation would read
the conversation data as a new file entry.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-04-06 15:24:13 -07:00
Graham Percival
b580147278
Fix #endif comments for header guards (#2567) 2025-04-06 14:16:24 -07:00
Graham Percival
ea9fd828dc
Use __LA_MODE_T to avoid implicit int conversions (#2478) 2025-04-06 14:13:17 -07:00
Graham Percival
81c43ea168
Fix missing newline at EOF (#2566) 2025-04-06 13:38:06 -07:00
Tobias Stoeckmann
89b8c35ff4
Improve lseek handling (#2564)
The skip functions are limited to 1 GB for cases in which libarchive
runs on a system with an off_t or long with 32 bits. This has negative
impact on 64 bit systems.

Instead, make sure that _all_ subsequent functions truncate properly.
Some of them already did and some had regressions for over 10 years.

Tests pass on Debian 12 i686 configured with --disable-largefile, i.e.
running with an off_t with 32 bits.

Casts added where needed to still pass MSVC builds.

---------

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-04-06 13:34:37 -07:00
Graham Percival
fed3712d6e
Reject bad hex values in xar checksums (#2479)
Hex values should be A to F (and lower-case); if there's any other
letters, reject them.
2025-04-06 09:29:16 +02:00
Graham Percival
1b6009d17b
Use explicit casts for some functions (#2480) 2025-04-06 09:26:53 +02:00
Tim Kientzle
29fd918e18
Issue 2548: Reading GNU sparse entries (#2558)
My attempt to fix #2404 just made the confusion between the size of the
extracted file and the size of the contents in the tar archive worse
than it was before.

@ferivoz in #2557 showed that the confusion stemmed from a point where
we were setting the size in the entry (which is by definition the size
of the file on disk) when we read the `GNU.sparse.size` and
`GNU.sparse.realsize` attributes (which might represent the size on disk
or in the archive) and then using that to determine whether to read the
value in ustar header (which represents the size of the data in the
archive).

The confusion stems from three issues:
* The GNU.sparse.* fields mean different things depending on the version
of GNU tar used.
* The regular Pax `size` field overrides the value in the ustar header,
but the GNU sparse size fields don't always do so.
* The previous libarchive code tried to reconcile different size
information as we went along, which is problematic because the order in
which this information appears can vary.

This PR makes one big structural change: We now have separate storage
for every different size field we might encounter. We now just store
these values and record which one we saw. Then at the end, when we have
all the information available at once, we can use this data to determine
the size on disk and the size in the archive.

A few key facts about GNU sparse formats:

* GNU legacy sparse format: Stored all the relevant info in an extension
of the ustar header.
* GNU pax 0.0 format: Used `GNU.sparse.size` to store the size on disk
* GNU pax 0.1 format: Used `GNU.sparse.size` to store the size on disk
* GNU pax 1.0 format: Used `GNU.sparse.realsize` to store the size on
disk; repurposed `GNU.sparse.size` to store the size in the archive, but
omitted this in favor of the ustar size field when that could be used.

And of course, some key precedence information:
* Pax `size` field always overrides the ustar header size field.
* GNU sparse size fields override it ONLY when they represent the size
of the data in the archive.

Resolves #2548
2025-03-30 09:26:25 -07: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
ARJANEN Loïc Jean David
6bb0952602
Commonalising time-related functions. (#2553)
Putting the time format conversion functions in one file and using the
common functions in the various formats.
2025-03-28 07:23:43 -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
ARJANEN Loïc Jean David
9ad0e27f53
Fix for the ZIP large file test (#2552)
Making the ZIP large file test use the utility functions too.
2025-03-24 19:20:21 -07:00
Peter Kokot
2c2266432f
CMake: Replace CMAKE_COMPILER_IS_GNUCC with CMAKE_C_COMPILER_ID (#2550)
Hello,

- The `CMAKE_COMPILER_IS_*` variables are deprecated and
`CMAKE_C_COMPILER_ID` can be used in this case instead.
- The legacy `endif()` command argument also simplified to avoid
repeating the condition.
2025-03-22 14:21:38 -07:00
nia
f8a34abfbb
Only use S_ISSOCK if available. (#2543)
Needed to build on OpenServer 5 Definitive 2018.
2025-03-18 06:17:03 -07:00
Nicholas Vinson
a323e5fa68
Move archive_entry_set_digest() to public API (#2540)
Moving archive_entry_set_digest() to the public API simplifies porting
non-archive formats to archive formats while preserving supported
message digests specifically in cases where recomputing digests is not
viable.
2025-03-16 16:37:47 -07:00
Tobias Stoeckmann
a88e09a370
Remove extra newline from error messages (#2541)
The lafe_errc function adds a newline by itself already, so do not
insert one into the message.

You can reproduce with the following commands:

```
touch archive.tar
bsdtar -xf archive.tar -C /non-existing
```

```
bsdtar --exclude ""
```

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-03-16 15:33:05 -07:00
ljdarj
09a2ed4853
FILE* seeking support (#2539)
Adding a seeker function to archive_read_open_FILE().

Fixes #437.
2025-03-15 11:17:27 -07:00
Martin Matuška
03e15babd6
CI: Update FreeBSD build environments (#2534)
FreeBSD 13.4 -> 13.5
FreeBSD 14.1 -> 14.2
2025-03-11 06:15:49 -07:00
Peter Kästle
c9bc934e7e
fix CVE-2025-1632 and CVE-2025-25724 (#2532)
Hi,

please find my approach to fix the CVE-2025-1632 and CVE-2025-25724
vulnerabilities in this pr.
As both error cases did trigger a NULL pointer deref (and triggered
hopefully everywhere a coredump), we can safely replace the actual
information by a predefined invalid string without breaking any
functionality.

---------

Signed-off-by: Peter Kaestle <peter@piie.net>
2025-03-10 08:43:04 -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
ljdarj
de77e6d671
Moving the tests' CRC-32 function to test_utils. (#2390)
Following up from #2284, putting the tests' CRC-32 implementation in
test_utils and having all tests use it.
2025-03-07 19:21:23 -08:00
Tim Kientzle
3512329ba9
Avoid unreachable code in this test (#2528)
As remarked in #2521, this test has unreachable code on Windows, which
triggers a build failure in development due to warnings-as-errors.
(Release versions should not have warnings-as-errors.)
2025-03-01 09:06:31 -08:00
François Degros
21f74252f2
Handle ARCHIVE_FILTER_LZOP in archive_read_append_filter (#2519)
Fixes #2513
2025-02-24 07:01:39 -08:00
ljdarj
b6f6557abb
Fixing up archive_read_format's man page. (#2518)
Adding the requested updates to the man pages.

Fixes libarchive#2507.
2025-02-22 09:06:28 -08:00
Stepan Tsepa
447201758e Make installation lib dir depend on CMAKE_INSTALL_LIBDIR variable 2025-02-14 11:34:56 +03:00
ljdarj
65196fdd1a
Remove dev_t and time_t from public API in 4.0 (#2392)
Removing dev_t and time_t from the public include files from 4.0 on and
updating some tests in consequence.

Fixes #2279 .
2025-01-25 10:14:42 -08:00
Jessica Clarke
27588eba50 Fix replacing a regular file with a dir for ARCHIVE_EXTRACT_SAFE_WRITES
The outer if checks !S_ISDIR(a->st.st_mode), so we know that the file
being overwritten is not a directory, and thus we can rename(2) over it
if we want to, but whether we can use a temporary regular file is a
property of the file being extracted. Otherwise, when replacing a
regular file with a directory, we end up in this case and create a
temporary regular file for the new directory, but with the permissions
of the directory (which likely includes x), and rename it over the top
at the end. Depending on where the archive_entry came from, it may have
a non-zero size that also isn't ovewritten with 0 (e.g. if it came from
stat(2)) and so the API user may then try to copy data (thus failing if
read(2) of directories isn't permitted, or writing the raw directory
contents if it is), but if the size is zero as is the case for this tar
test then it will end up not writing any data and "successfully"
overwrite the file with an empty file, not a directory.
2025-01-07 20:59:09 +00:00
Graham Percival
42565b88b5
Cast (mode_t)mode for POSIX functions (#2476) 2025-01-06 16:44:40 -08:00
Mostyn Bramley-Moore
743bbe9769
Fix another GCC version detection error (#2474)
This is another instance of the same bug that was fixed in #2472.
2025-01-01 15:36:17 -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
Sam James
a186d9662b
Fix GCC version detection for __attribute__((deprecated)) (#2472)
The #if condition as-written fails for any major >= 3 if minor < 1, e.g.
GCC 15.0 (while in development).

Use the idiom described in the GCC docs [0] to avoid this.

[0] https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html

Fixes: ab94a813b0f64cbc1bcb952bf55424a2d9c7f1d9
2025-01-01 10:56:51 -08:00
Silent
14b8803c40
Fix a Y2038 bug by replacing Int32x32To64 with regular multiplication (#2471)
`Int32x32To64` macro internally truncates the arguments to int32, while
`time_t` is 64-bit on most/all modern platforms. Therefore, usage of
this macro creates a Year 2038 bug.

I detailed this issue a while ago in a writeup, and spotted the same
issue in this repository when updating the list of affected
repositories:
<https://cookieplmonster.github.io/2022/02/17/year-2038-problem/>

A few more notes:
1. I changed all uses of `Int32x32To64` en masse, even though at least
one of them was technically OK and used with int32 parameters only. IMO
better safe than sorry.
2. This is untested, but it's a small enough change that I hope the CI
success is a good enough indicator.
2025-01-01 08:31:35 -08:00
Graham Percival
25c3d9afea
Fix compiler nitpicks (#2470) 2024-12-30 19:42:04 -08:00
Graham Percival
982747fd66
Fix compiler nitpicks (#2469) 2024-12-30 13:31:48 -08:00
Mostyn Bramley-Moore
adc54b374e
Fix MSVC conversion from DWORD to short warning (#2468) 2024-12-30 08:32:39 -08:00
Mostyn Bramley-Moore
ef3f9c45d5
Fix MSVC zstd conversion from size_t to int warnings (#2467) 2024-12-30 08:32:01 -08:00
Mostyn Bramley-Moore
1427f3431d
Detect endianness at build time for common MSVC targets also (#2466)
This should now cover the most common build targets.
2024-12-30 08:31:14 -08:00
Graham Percival
edcae6c164
Fix compiler nitpicks (#2465) 2024-12-30 08:30:42 -08:00
Mostyn Bramley-Moore
561b6430fd
Prefer build-time endianness detection (#2464)
Endianness is easy to determine at runtime, but detecting this a single
time and then reusing the cached result might require API changes.

However we can use compile-time detection for some known compiler macros
without API changes fairly easily. Let's start by enabling this for
Clang and GCC.
2024-12-29 18:10:23 -08:00
Graham Percival
4ce9c2f4be
Add more casts for %c, %o, and %x (#2463) 2024-12-29 10:20:24 -08:00
Graham Percival
dc5e1405b6
Spelling fixes for func, struct, and macros (#2462) 2024-12-29 10:19:21 -08:00
Graham Percival
a2086b67d8
Add more casts for %o (#2461) 2024-12-29 10:18:06 -08:00
Graham Percival
14221c7ba2
Add straightforward casts for %o and %x (#2458) 2024-12-28 16:29:47 -08:00
Mostyn Bramley-Moore
28cb5064d8
7zip reader: add support for POWERPC filter for non-LZMA compressors (#2459)
This new test archive contains a C hello world executable built like so
on a ubuntu 24.04 machine:
```
#include <stdio.h>

int main(int argc, char *argv[]) {
  printf("hello, world\n");
  return 0;
}
```

`powerpc-linux-gnu-gcc hw.c -o hw-powerpc -Wall`

The test archive that contains this executable was created like so,
using 7-Zip 24.08:
`7zz a -t7z -m0=deflate -mf=ppc
libarchive/test/test_read_format_7zip_deflate_powerpc.7z hw-powerpc`

This test fails in the first commit in this PR, and passes in the second
commit.
2024-12-28 15:36:01 -08:00
Graham Percival
a659a44a85
Fix format strings (#2457) 2024-12-28 11:03:17 -08:00
Graham Percival
b557c1f161
Add tar/test/test_list_item (#2454) 2024-12-28 11:01:19 -08:00
Tim Kientzle
12517fa78d
Fix the test for NOABSOLUTEPATHS (#2456)
The test inadvertently tried to manipulate the wrong archive at one
point.
2024-12-27 15:51:33 -08:00
Stephane Chazelas
4d5106f2b5
tar: fix bug when -s/a/b/ used more than once with b flag (#2435)
When the -s/regexp/replacement/ option was used with the b flag more
than once, the result of the previous substitution was appended to the
previous subject instead of replacing it. Fixed it by making sure the
subject is made the empty string before the call to realloc_strcat().
That in effect makes it more like a realloc_strcpy(), but creating a new
realloc_strcpy() function for that one usage doesn't feel worth it.

Resolves Issue libarchive/libarchive#2414

Co-authored-by: Stephane Chazelas <stephane@chazelas.org>
2024-12-27 15:20:16 -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
Mostyn Bramley-Moore
e6d8a479b1
ci: use at most the number of make threads as there are cores on mac and linux github runners (#2437)
We previously told make to run as many threads as it likes on these CI
jobs, but that might sometimes hit resource limits like RAM or the
allowed number of open files.

These numbers were found experimentally by using `sysctl -n hw.ncpu` on
mac and `nproc` on linux.
2024-12-27 12:40:47 -08:00
Graham Percival
0acaa2994a
Fix remaining TODOs in test_stdio.c (#2444) 2024-12-27 12:38:03 -08:00
Graham Percival
35da265cc3
Remove unnecessary semicolons (#2450) 2024-12-25 09:35:54 -08:00
Graham Percival
0d1ac07d3f
Remove unreachable 'break' statements (#2451) 2024-12-25 09:33:11 -08:00
Graham Percival
a17bded84a
Fix %d -> %u for unsigned int from i4le() (#2448)
`i4le()` returns an unsigned int, so `'%d'` is incorrect.

Reported by `clang -Wformat`. (Many more such fixes to come, but this is
the simplest set of them.)
2024-12-24 15:27:26 -08:00
Graham Percival
e99c6d69f1
Fix CRLF line endings in source files (#2449) 2024-12-24 15:25:53 -08:00
Graham Percival
af4a3562cd
Reject relative path for test refdir (#2445) 2024-12-24 11:51:50 -08:00
Graham Percival
1f6cdd4625
Fix a few clang nitpicks (#2447)
Fixes warnings found by:
```
-Wformat-non-iso
-Wnewline-eof
-Wmissing-variable-declarations
```
2024-12-24 11:50:19 -08:00
Graham Percival
72bbf9ec25
Fix some TODOs in tar/test/test_stdio.c (#2442) 2024-12-19 14:24:57 -08:00
Mostyn Bramley-Moore
819a50a043
Remove liblzmadec remnants (#2436)
It looks like support for this library was removed in 2016, but we still
had some unused cmake code and a dead preprocessor block.
2024-12-15 23:14:57 +01:00
Mostyn Bramley-Moore
ee9b638fba
7zip reader: add LZMA + RISCV BCJ filter (#2403)
7-Zip 24.05 and liblzma 5.5.1alpha added a RISC-V BCJ filter. Let's
enable this combination if we can.

Note that this does not allow the use of the RISC-V filter with other
compressors.
2024-12-15 23:12:02 +01:00
Mostyn Bramley-Moore
b0d48940f8
7zip writer: support multithreaded zstandard compression (#2391)
Command example:
bsdtar -cavf /tmp/foo.7z --options='compression=zstd,threads=4' *
2024-12-15 23:10:17 +01:00
Mostyn Bramley-Moore
6516cd137e
Remove unnecessary HAVE_LZMA_FILTER_ARM64 feature check (#2433)
It is sufficent to use HAVE_LZMA_H and then check for macros defined in
lzma.h
2024-12-10 20:35:16 -08:00
Tim Kientzle
8291210321
Handle truncation in the middle of a GNU long linkname (#2422)
Thanks to gbdngb12 김동건 for reporting this.

Resolves Issue #2415
2024-12-09 21:09:29 -08:00
Mostyn Bramley-Moore
7efa99bdb1
ci: make skipped tests more obvious (#2430)
Previously skipped tests were reported like this when running the *_test
binaries:
```
 4: test_acl_platform_nfs4                                          ok (S)
```

Let's make this more obvious:
```
  4: test_acl_platform_nfs4                                         skipped
```
2024-12-08 18:08:34 -08:00
Mostyn Bramley-Moore
8ac45a813e
Report skipped tests to cmake/ctest (#2429)
This plumbing is required for cmake/ctest to recognise and report
skipped tests.

Now skipped tests in cmake ci jobs are reported like so:
```
          Start   7: libarchive_test_acl_platform_posix1e_read
    7/785 Test   #7: libarchive_test_acl_platform_posix1e_read ................................***Skipped   0.02 sec
```

And there is a list of skipped tests shown at the end of the test run.
2024-12-08 18:07:49 -08:00
Mostyn Bramley-Moore
ba76798136
ci: speed up windows/mingw build by using multiple make jobs (#2428)
This decreases the "Install library dependencies" step duration from
~4min to ~2min, and the "Build" step duration from ~10min to ~4min.
2024-12-07 16:39:46 -08:00
Mostyn Bramley-Moore
29802f6a5e
ci: make autoconf look for headers and libraries in /opt/homebrew if those directories exist (#2427)
Prior to this change, the ci autoconf jobs weren't looking for homebrew
headers or libraries unless pkg-config was used, so for example the
"MacOS (autotools)" ci job wasn't testing lz4 or zstd code.

Relates to #2426.
2024-12-07 15:11:19 -08:00
Mostyn Bramley-Moore
0bbbe2883e
ci: log bsdtar's version text, so we can see which support libraries were used (#2426)
A few of libarchive's CI jobs don't find all the local support libraries
that they could be using. This change makes it easier to see which of
them are used.
2024-12-07 15:10:42 -08:00
Mostyn Bramley-Moore
9b7540aaf1
ci: find liblzma >= 5.6.3 on windows msvc tests (#2421)
We currently use XZ Utils 5.6.3 on windows CI jobs, but the Windows
(msvc)
job which uses cmake seems to only be looking for the old library name,
liblzma.lib:

```
-- Looking for lzma_auto_decoder in C:/Program Files (x86)/xz/lib/liblzma.lib
-- Looking for lzma_auto_decoder in C:/Program Files (x86)/xz/lib/liblzma.lib - not found
-- Looking for lzma_easy_encoder in C:/Program Files (x86)/xz/lib/liblzma.lib
-- Looking for lzma_easy_encoder in C:/Program Files (x86)/xz/lib/liblzma.lib - not found
-- Looking for lzma_lzma_preset in C:/Program Files (x86)/xz/lib/liblzma.lib
-- Looking for lzma_lzma_preset in C:/Program Files (x86)/xz/lib/liblzma.lib - not found
-- Could NOT find LibLZMA (missing: LIBLZMA_HAS_AUTO_DECODER LIBLZMA_HAS_EASY_ENCODER LIBLZMA_HAS_LZMA_PRESET) (found version "5.6.3")
```

We need to update build/ci/github_actions/ci.cmd to look for lzma.lib
instead.
2024-12-06 19:56:06 -08:00
Graham Percival
f745a848d7
Spelling fixes (#2412) 2024-12-06 08:00:03 -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
Julian Uy
b5d95321d4
Add missing definition for getline polyfill (#2425)
The fallback for when `getline` is not implemented in libc was not
compiling due to the fact that the definition for it was missing, so add
the definition.
2024-12-06 07:57:27 -08:00
Alexander Ziaee
68238f28ee
bsdtar.1: Mention rar support + manual page polish (#2423)
I have been using this for years without realizing it decompresses rar.

+ add rar to supported decompression formats
+ use section references to link sections (this makes them clickable in
GUIs)
+ add paragraph breaks for consistent spacing
+ pdtar is not this program, so use Sy per mdoc style guide
+ do almost the same in reverse for bsdtar
+ remove parenthetical around a complete sentance

Thank you so much, this is wonderful software.
2024-12-06 07:50:06 -08:00
Mostyn Bramley-Moore
84ad874530
Test with XZ Utils 5.6.3 on windows CI jobs (#2417)
This change fixes the autotools build to work with xz-utils 5.6.3, which
changed library names on windows, and fixes a couple of tests that I
noticed had dependencies on liblzma.
2024-12-02 00:29:46 +01:00
MithicSpirit
cbfe4d9e6d
nit(tar): fix typo (#2420) 2024-11-30 22:21:45 -05:00
ljdarj
e37d378186
Moving the tests' integer reading functions to test_utils. (#2410)
Moving the tests' integer reading functions to test_utils so that they
all use the same as well as moving the few using the archive_endian
functions over to the test_utils helper.

Follow-up from libarchive#2390.
2024-11-16 17:42:27 -08:00
Tim Kientzle
d60f3ea1b3
Ignore ustar size when pax size is present (#2405)
When the pax `size` field is present, we should ignore the size value in
the ustar header. In particular, this fixes reading pax archives created
by GNU tar with entries larger than 8GB.

Note: This doesn't impact reading pax archives created by libarchive
because libarchive uses tar extensions to store an accurate large size
field in the ustar header. GNU tar instead strictly follows ustar in
this case, which prevents it from storing accurate sizes in the ustar
header.

Resolves #2404
2024-11-06 22:21:54 +01:00
Mostyn Bramley-Moore
974b59113d
7zip reader: add SPARC filter support for non-LZMA compressors (#2399)
These two new test archives contain a C hello world executable built
like so on a ubuntu 24.04 machine:

```
#include <stdio.h>

int main(int argc, char *argv[]) {
  printf("hello, world\n");
  return 0;
}
```

`sparc64-linux-gnu-gcc hw.c -o hw-sparc64 -Wall`

The two test archives that contain this executable were created like so,
using the https://github.com/tehmul/p7zip-zstd fork of 7-Zip:
`7z a -t7z -m0=zstd -mf=SPARC
libarchive/test/test_read_format_7zip_zstd_sparc.7z hw-sparc64`
`7z a -t7z -m0=lzma2 -mf=SPARC
libarchive/test/test_read_format_7zip_lzma2_sparc.7z hw-sparc64`

Two test files are required, because the 7zip reader code has two
different paths, one for lzma and one for all other compressors.

The test_read_format_7zip_lzma2_sparc test is expected to pass, because
LZMA BCJ filters are implemented in liblzma.

The test_read_format_7zip_zstd_sparc test is expected to fail in the
first commit, because libarchive does not currently implement the SPARC
BCJ filter. The second commit will make test_read_format_7zip_zstd_sparc
pass.
2024-10-28 19:29:23 -07:00
Tim Kientzle
e36d6fe935
Revert "Use proper Create OS value on Windows to fix archive charset detection (#2240) (#2401)
Two problems are prompting this revert:

* In order to change the Create OS value to "Windows", we would need to
record other data (such as `external_attributes`) in Windows format as
well.

* Changing the Create OS value doesn't actually fix the
filename-encoding issue that originally motivated this PR

This reverts commit 755af84301adc4262722a4c88671a8d0a1c83fae.
2024-10-27 19:34:51 -07:00
Mostyn Bramley-Moore
87fa733679
Rename bsdtar test_extract_tar_absolute_paths source file for consistency (#2400)
The `-P` flag is uppercase, so the test file should be named
test_option_P_upper.c for consistency with the other test files in this
directory.

Sorry about the noise.
2024-10-27 08:43:59 -07:00
Martin Matuška
2cea675da2
tests: redirect stdout in one call in test_extract_tar_absolute_paths (#2386)
This redirects the message "Removing leading '/' from member names"
from stderr to a file in one case.
2024-10-25 18:45:28 +01:00
Martin Matuska
043b6feeef Fix tests added in #2284 (#2387) 2024-10-23 18:47:32 +02:00
Martin Matuska
206df6192c Revert "add --mac-metadata test for --format zip - see #2041 (#2045)"
This reverts commit ea56096020e2c6c764052adfab63e11fd745f9de.
2024-10-23 18:45:23 +02:00
nielash
ea56096020
add --mac-metadata test for --format zip - see #2041 (#2045)
Submitting this test at the request of @kientzle on issue #2041.

Note that failure is currently expected, as the feature it tests is not
yet implemented!
2024-10-22 11:16:55 +02:00
Dustin L. Howett
e619342dfa
write_xar: move libxml2 behind an abstraction layer (#1849)
This commit prepares the XAR writer for another XML writing backend.

Almost everything in this changeset leaves the code identical to how
it started, except for a new layer of indirection between the xar writer
and the XML writer.

The things that are not one-to-one renames include:
- The removal of `UTF8Toisolat1` for the purposes of validating UTF-8
- The writer code made a copy of every filename for the purposes of
  checking whether it was Latin-1 stored as UTF-8. In xar, Non-Latin-1
  gets stored Base64-encoded.
- I've replaced this use because (1) it was inefficient and (2)
  `UTF8Toisolat1` is a `libxml2` export.
- The new function has slightly different results than the one it is
  replacing for invalid UTF-8. Namely, it treats illegal UTF-8 "overlong"
  encodings of Latin-1 codepoints as _invalid_. It operates on the principle
  that we can determine whether something is Latin-1 based entirely on how
  long the sequence is expected to be.
- The move of `SetIndent` to before `StartDocument`, which the
  abstraction layer immediately undoes. This is to accommodate XML writers 
  that require indent to be set _before_ the document starts.
2024-10-22 11:10:50 +02: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
ljdarj
15c686c55f
Adding XZ, LZMA, ZSTD and BZIP2 support to ZIP writer (#2284)
PPMD may come later but I'd rather first iron out style issues with the
ones needing only to wire up libraries already-used in Libarchive before
going at the ones possibly requiring implementing algorithms as well.

Closes #1046 and resolves #1179.
2024-10-22 10:58:22 +02:00
unxed
755af84301
Use proper Create OS value on Windows to fix archive charset detection (#2240)
See https://sourceforge.net/p/sevenzip/bugs/2463
2024-10-22 10:56:19 +02:00
Dustin L. Howett
ac43e8e3fe
Reintroduce size_t cast to clarify the use of a u32 shift on a u64 arg (#2383)
Regressed in #2285
2024-10-22 10:52:19 +02:00
vcoxvco
40ff837717
Various small fixes for Cygwin, Haiku, OpenIndiana (#2346)
Cygwin 3.5.4 (same applies for 3.5.3),
I get a compile error as shown below after a simple ./configure and
make. Adding <windef.h> solves the problem.

Co-authored-by: vco <god@universe.sys>
2024-10-14 08:44:17 -07:00
Martin Matuška
d8c3b97b31
tests: use const char instead of char in one case (#2381)
Found in test_extract_cpio_absolute_paths.c when compiling FreeBSD base
2024-10-13 13:41:06 -07:00
Tim Kientzle
971c043a1d
Ignore checksum mismatches when fuzzing tar archives (#2378)
This should speed up fuzzing just a bit, so we
can find more bugs!
2024-10-13 09:42:38 +02:00
dependabot[bot]
295f47a074
CI: Bump the all-actions group across 1 directory with 4 updates (#2379)
Bumps the all-actions group with 4 updates:

actions/checkout from 4.1.6 to 4.2.1
actions/upload-artifact from 4.3.3 to 4.4.3
github/codeql-action from 3.25.6 to 3.26.12
ossf/scorecard-action from 2.3.3 to 2.4.0

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-13 09:42:01 +02:00
Tim Kientzle
aada018f05
Increase the hole size for this test to 32MiB (#2380)
APFS on macOS 15 seems to have a higher threshold for creating sparse
files.
2024-10-13 09:35:17 +02:00
Emil Velikov
6287b99eb7
Convert the tools and respective tests to SPDX (#2317)
This is the first part of converting the project to use SPDX license
identifiers instead using the verbose license text.

The patches are semi-automated and I've went through manually to ensure
no license changes were made. That said, I would welcome another pair of
eyes, since I am only human.

See https://github.com/libarchive/libarchive/issues/2298

---------

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2024-10-12 20:54:16 -07:00
Christian Schmitz
b8d7e074c1
Update archive_private to avoid template keyword (#2342)
People really should never, ever, ever use libarchive internal headers.  And they definitely should not expect libarchive internal headers to work in a C++ compiler.  (C++ and C are really just not that compatible.)

However, people do a lot of things they shouldn't:  Avoid the reserved C++ keyword `template`
2024-10-12 17:47:30 -07:00
vcoxvco
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 Matuška
c0ce80b970
CI: Update build environments (#2373)
FreeBSD 13.3 -> 13.4
FreeBSD 14.0 -> 14.1
Ubuntu 22.04 -> 24.04
2024-10-12 09:31:20 -07:00
Tim Kientzle
3343bb8a28
Fix two leaks in tar header parsing (#2377)
OSS-Fuzz found two places where an error return would bypass cleaning up
a local allocation.

Credit: OSS-Fuzz
2024-10-12 13:54:23 +02:00
Martin Matuška
10c817cdc3
tests: change file format from dos to unix in one test file (#2376) 2024-10-11 20:54:59 -07:00
Duncan Horn
2121da4bbb
[7zip] Read/write symlink paths as UTF-8 (#2252)
I previously tried to find documentation on how symlinks are expected to
be stored in 7zip files, however the best reference I could find was
[here](https://py7zr.readthedocs.io/en/latest/archive_format.html). That
site suggests that symlink paths are stored as UTF-8 encoded strings:
2024-10-11 08:30:25 +02:00
Duncan Horn
6177e4d0c0
Update RAR5 code to report encryption (#2096)
Currently, the RAR5 code always reports
`ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED` for
`archive_read_has_encrypted_entries`, nor does it set any of the
entry-specific properties, even though it has enough information to
properly report this information. Accurate reporting of encryption is
super useful for applications because reporting an error message such as
"the archive is encrypted, but we don't currently support encryption" is
a lot better than a not generally useful `errno` value and a
non-localizable error string with a confusing and unpredictable error
message.

Fixes #1661
2024-10-11 08:25:47 +02:00
ljdarj
e4068fb87c
Change to Windows absolute symlinks. (#2362)
Change to read absolute symlinks as verbatim paths instead of NT paths:
as far as I can see, libarchive can deal with verbatim paths while it
can't with NT ones.

Fixes #2274.
2024-10-11 08:18:55 +02:00
Michał Górny
94da78b084
configure.ac: remove incorrect 4th argument to AC_CHECK_FUNCS (#2334)
Remove the incorrect 4th argument from `AC_CHECK_FUNCS` calls. The macro
uses only three arguments, so it was ignored anyway. Furthermore, in at
least once instance it was wrong -- due to a typo in `attr/xatr.h`
header name.
2024-10-11 08:17:01 +02:00
Tim Kientzle
565b5aea49
Don't crash on truncated tar archives (#2364)
The tar header parsing overhaul in #2127 introduced a systematic
mishandling of truncated files: the code incorrectly checks for whether
a given read operation failed, and ends up dereferencing a NULL pointer
in this case. I've gone back and double-checked how
`__archive_read_ahead` actually works (it returns NULL precisely when it
was unable to satisfy the read request) and reworked the error handling
for each call to this function in archive_read_support_format_tar.c

Resolves #2353
Resolves https://issues.oss-fuzz.com/issues/42537231
2024-10-11 08:16:12 +02:00
Tim Kientzle
b34c1f4def
Sanity-check gzip header field length (#2366)
OSS-Fuzz managed to construct a small gzip input that decompresses into
another gzip input with an extremely large filename field. This causes
libarchive to hang processing the inner gzip.

Address this by rejecting any gzip input where the filename or comment
fields exceed 1MiB.

Credit: OSS-Fuzz
2024-10-11 08:14:58 +02:00
Tim Kientzle
35e630174e
Clarify crc32 variable names (#2367)
No functional change, just a tiny style improvement.

Use `crc32_computed` to refer to the crc32 that the reader has computed
and `crc32_read` to refer to the value that we read from the archive.
That hopefully makes this code a tiny bit easier to follow. (It confused
me recently when I was double-checking something in this area, so I
thought an improvement here might help others.)
2024-10-11 08:13:00 +02:00
Tim Kientzle
41a2d01453
Fix error message printing (#2368)
We always print the error message with or without -v, but for some
reason, we were omitting the path being processed. Simplify so that we
always print the full error including context.
2024-10-11 08:11:43 +02:00
Steve Lhomme
08ab094ea7
Don't use Windows bcrypt when building for Windows XP or older (#2374)
The header may be detected but we can't use the calls.

The same check is already done in many places but not all of them.
2024-10-08 21:06:57 -07:00
Mostyn Bramley-Moore
a65f765f17
bsdcpio should exit with an error code if an entry can't be extracted (#2371)
For example if --insecure is not specified, and one of the security
checks fails.
2024-10-07 08:51:17 -07:00
Mostyn Bramley-Moore
d6dd082adf
Add absolute path test for bsdtar (#2370)
Check that extracting archive entries with absolute paths uses mangled
relative paths unless -P / --absolute-paths is specified.
2024-10-06 20:35:28 -07:00
Mostyn Bramley-Moore
62ce582d1c
Simplify tests added in #2363, use testworkdir (#2369) 2024-10-06 20:34:58 -07:00
Martin Matuška
9d5289ae9e
Fix pathname overwrite in header_old_tar() (#2360)
Fixes #2359
2024-10-06 20:31:38 -07:00
Dag-Erling Smørgrav
a90e9d84ec
Miscellaneous code cleanup (#2285)
This fixes various code quality issues I encountered while chasing a
memory leak reported by test automation. I failed to reproduce the
memory leak, but I hope you find this useful nonetheless.
2024-10-04 08:45:58 -07:00
Mostyn Bramley-Moore
2fd35b0fdb
Fix ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS on windows (#2363) 2024-10-04 08:36:56 -07:00
Mostyn Bramley-Moore
6567375f27
Reenable CI tests for MSVC (#2356)
These were disabled when migrating from Cirrus CI. Let's enable them for
github workflows, disable any failing tests on this configuration and
leave TODO notes to fix them.

This was the only failure that I found:
```
  684/764 Test #684: bsdtar_test_option_ignore_zeros_mode_c ...................................***Failed    0.10 sec
  
  If tests fail or crash, details will be in:
     C:\Users\RUNNER~1\AppData\Local\Temp/bsdtar_test.exe.2024-09-29T11.42.13-000
  
  Reference files will be read from: D:/a/libarchive/libarchive/tar/test
  Running tests on: "D:\a\libarchive\libarchive\build_ci\cmake\bin\Release\bsdtar.exe"
  Exercising: bsdtar 3.8.0 - libarchive 3.8.0dev zlib/1.3 liblzma/5.4.4 bz2lib/1.1.0 libzstd/1.5.5 
  
   39: test_option_ignore_zeros_mode_c
  D:\a\libarchive\libarchive\tar\test\test_option_ignore_zeros.c(99): File should be empty: test-c.err
      File size: 112
      Contents:
  0000 62 73 64 74 61 72 2e 65 78 65 3a 20 61 3a 20 43 bsdtar.exe: a: C
  0010 61 6e 27 74 20 74 72 61 6e 73 6c 61 74 65 20 75 an't translate u
  0020 6e 61 6d 65 20 27 28 6e 75 6c 6c 29 27 20 74 6f name '(null)' to
  0030 20 55 54 46 2d 38 0d 0a 62 73 64 74 61 72 2e 65  UTF-8..bsdtar.e
  0040 78 65 3a 20 62 3a 20 43 61 6e 27 74 20 74 72 61 xe: b: Can't tra
  0050 6e 73 6c 61 74 65 20 75 6e 61 6d 65 20 27 28 6e nslate uname '(n
  0060 75 6c 6c 29 27 20 74 6f 20 55 54 46 2d 38 0d 0a ull)' to UTF-8..
  
  Totals:
    Tests run:                1
    Tests failed:             1
    Assertions checked:      21
    Assertions failed:        1
    Skips reported:           0
```
2024-09-29 21:36:48 -07:00
Tim Kientzle
4b6dd229c6
Remove two unnecessary strings from the tar state (#2345)
`pax_global` is not used at all and can be removed.

`longname` is only used locally within one function, so convert it to a
local variable there.
2024-09-24 19:12:11 -07:00
Tim Kientzle
75cdc59470
Clean up linkpath between entries (#2343)
PR #2127 failed to clean up the linkpath storage between entries. As a
result, after the first hard/symlink entry in a pax format archive, all
subsequent entries would get the same link information.

I'm really unsure how this bug failed to trip CI. I'll do some digging
in the test suite before I merge this.

Resolves #2331 , #2337

P.S. Thanks to Brad King for noting that the linkpath wasn't being
managed correctly, which was a big hint for me.
2024-09-23 01:06:34 +02:00
Michał Górny
fa7e9cd7cb
tar/write.h: Support sys/xattr.h (#2335)
Synchronize the last use of `attr/xattr.h` to support using
`sys/xattr.h` instead. The former header is deprecated on GNU/Linux, and
this replacement makes it possible to build libarchive without the
`attr` package.
2024-09-20 19:44:06 -07:00
Brad King
7c3980367e
tar: fix memory leaks when processing symlinks or parsing pax headers (#2338)
Fix memory leaks introduced by #2127:

* `struct tar` member `entry_linkpath` was moved at the same time as
   other members were removed, but its cleanup was accidentally removed
   with the others.

* `header_pax_extension` local variable `attr_name` was not cleaned up.

Resolves #2336
2024-09-20 14:11:43 +02:00
Tim Kientzle
e939c97a57
Be more cautious about parsing ISO-9660 timestamps (#2330)
Some ISO images don't have valid timestamps for the root directory
entry. Parsing such timestamps can generate nonsensical results, which
in one case showed up as an unexpected overflow on a 32-bit system.

Add some validation logic that can check whether a 7-byte or 17-byte
timestamp is reasonable-looking, and use this to ignore invalid
timestamps in various locations. This also requires us to be a little
more careful about tracking which timestamps are actually known.

Resolves issue #2329
2024-09-19 22:20:02 -07:00
Martin Matuska
915c9f83a4 Libarchive 3.8.0dev 2024-09-13 23:13:01 +02:00
551 changed files with 39221 additions and 7928 deletions

View File

@ -1,3 +1,4 @@
---
env:
CIRRUS_CLONE_DEPTH: 1
ARCH: amd64
@ -9,22 +10,33 @@ FreeBSD_task:
env:
BS: cmake
matrix:
freebsd_instance:
image_family: freebsd-14-0
freebsd_instance:
image_family: freebsd-13-3
- name: 15.0-STABLE (UFS)
freebsd_instance:
image_family: freebsd-15-0-amd64-ufs-snap
- name: 15.0-RELEASE (UFS)
freebsd_instance:
image_family: freebsd-15-0-amd64-ufs
- name: 15.0-RELEASE (ZFS)
freebsd_instance:
image_family: freebsd-15-0-amd64-zfs
- name: 14.3-RELEASE
freebsd_instance:
image_family: freebsd-14-3
- name: 13.5-RELEASE
freebsd_instance:
image_family: freebsd-13-5
prepare_script:
- ./build/ci/cirrus_ci/ci.sh prepare
configure_script:
- env CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ./build/ci/build.sh -a autogen
- env CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ./build/ci/build.sh -a configure
- env MAKE=gmake CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ./build/ci/build.sh -a configure
build_script:
- env MAKE_ARGS="-j 2" ./build/ci/build.sh -a build
- env MAKE=gmake MAKE_ARGS="-j 2" ./build/ci/build.sh -a build
test_script:
- env SKIP_TEST_RESTORE_ATIME=1 MAKE_ARGS="-j 2" ./build/ci/build.sh -a test
- env MAKE=gmake SKIP_TEST_RESTORE_ATIME=1 MAKE_ARGS="-j 2" ./build/ci/build.sh -a test
- ./build/ci/cirrus_ci/ci.sh test
install_script:
- env MAKE_ARGS="-j 2" ./build/ci/build.sh -a install
- env MAKE=gmake MAKE_ARGS="-j 2" ./build/ci/build.sh -a install
Windows_Cygwin_task:
windows_container:

View File

@ -7,14 +7,14 @@ permissions:
jobs:
MacOS:
runs-on: macos-13
runs-on: macos-15
strategy:
matrix:
bs: [autotools, cmake]
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Install dependencies
run: ./build/ci/github_actions/macos.sh prepare
run: ./build/ci/github_actions/install-macos-dependencies.sh
- name: Autogen
run: ./build/ci/build.sh -a autogen
env:
@ -23,41 +23,43 @@ jobs:
run: ./build/ci/build.sh -a configure
env:
BS: ${{ matrix.bs }}
# Avoid using liblzma from the Xcode 16 / MacOSX15.0.sdk, which fails RISCV filter tests.
CMAKE_ARGS: -D LIBLZMA_LIBRARY=/opt/homebrew/lib/liblzma.dylib -D LIBLZMA_INCLUDE_DIR=/opt/homebrew/include/lzma.h
- name: Build
run: ./build/ci/build.sh -a build
env:
BS: ${{ matrix.bs }}
MAKE_ARGS: -j
MAKE_ARGS: -j3
- name: Test
run: ./build/ci/build.sh -a test
env:
BS: ${{ matrix.bs }}
SKIP_OPEN_FD_ERR_TEST: 1
IGNORE_TRAVERSALS_TEST4: 1
MAKE_ARGS: -j
MAKE_ARGS: -j3
CTEST_OUTPUT_ON_FAILURE: ON
- name: Install
run: ./build/ci/build.sh -a install
env:
BS: ${{ matrix.bs }}
MAKE_ARGS: -j
MAKE_ARGS: -j3
- name: Artifact
run: ./build/ci/build.sh -a artifact
env:
BS: ${{ matrix.bs }}
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: libarchive-macos-${{ matrix.bs }}-${{ github.sha }}
path: libarchive.tar.xz
Ubuntu:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
bs: [autotools, cmake]
crypto: [mbedtls, nettle, openssl]
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Update apt cache
run: sudo apt-get update
- name: Install dependencies
@ -75,13 +77,13 @@ jobs:
run: ./build/ci/build.sh -a build
env:
BS: ${{ matrix.bs }}
MAKE_ARGS: -j
MAKE_ARGS: -j4
- name: Test
run: ./build/ci/build.sh -a test
env:
BS: ${{ matrix.bs }}
SKIP_OPEN_FD_ERR_TEST: 1
MAKE_ARGS: -j
MAKE_ARGS: -j4
CTEST_OUTPUT_ON_FAILURE: ON
- name: Install
run: ./build/ci/build.sh -a install
@ -91,14 +93,14 @@ jobs:
run: ./build/ci/build.sh -a artifact
env:
BS: ${{ matrix.bs }}
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: libarchive-ubuntu-${{ matrix.bs }}-${{ matrix.crypto }}-${{ github.sha }}
path: libarchive.tar.xz
Ubuntu-distcheck:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Update package definitions
run: sudo apt-get update
- name: Install dependencies
@ -113,7 +115,7 @@ jobs:
SKIP_OPEN_FD_ERR_TEST: 1
- name: Dist-Artifact
run: ./build/ci/build.sh -a dist-artifact
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: libarchive-${{ github.sha }}
path: libarchive-dist.tar
@ -125,7 +127,7 @@ jobs:
matrix:
be: [mingw-gcc, msvc]
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Install mingw
if: ${{ matrix.be=='mingw-gcc' }}
run: choco install mingw
@ -161,7 +163,7 @@ jobs:
shell: cmd
env:
BE: ${{ matrix.be }}
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: libarchive-windows-${{ matrix.be }}-${{ github.sha }}
path: libarchive.zip

View File

@ -21,7 +21,7 @@ jobs:
fuzz-seconds: 600
dry-run: false
- name: Upload Crash
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts

View File

@ -26,18 +26,18 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Initialize CodeQL
uses: github/codeql-action/init@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6
uses: github/codeql-action/init@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
with:
languages: ${{ matrix.language }}
queries: +security-and-quality
- name: Autobuild
uses: github/codeql-action/autobuild@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6
uses: github/codeql-action/autobuild@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6
uses: github/codeql-action/analyze@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
with:
category: "/language:${{ matrix.language }}"

View File

@ -29,12 +29,12 @@ jobs:
steps:
- name: "Checkout code"
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
with:
results_file: results.sarif
results_format: sarif
@ -52,7 +52,7 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: SARIF file
path: results.sarif
@ -60,6 +60,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6
uses: github/codeql-action/upload-sarif@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
with:
sarif_file: results.sarif

View File

@ -1,21 +1,11 @@
#
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR)
if(APPLE AND CMAKE_VERSION VERSION_LESS "3.17.0")
message(WARNING "CMake>=3.17.0 required to make the generated shared library have the same Mach-O headers as autotools")
endif()
cmake_minimum_required(VERSION 3.17 FATAL_ERROR)
if(POLICY CMP0065)
cmake_policy(SET CMP0065 NEW) #3.4 don't use `-rdynamic` with executables
endif()
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW) #3.12.0 `find_package()`` uses ``<PackageName>_ROOT`` variables.
endif()
if(POLICY CMP0075)
cmake_policy(SET CMP0075 NEW) #3.12.0 `check_include_file()`` and friends use ``CMAKE_REQUIRED_LIBRARIES``.
endif()
#
PROJECT(libarchive C)
#
# Include standard installation directories
include(GNUInstallDirs)
#
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake")
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${libarchive_BINARY_DIR}/bin)
@ -29,7 +19,7 @@ endif()
# MinSizeRel : Release Min Size build
# None : No build type
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build Type" FORCE)
SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build Type" FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
# Set a value type to properly display CMAKE_BUILD_TYPE on GUI if the
# value type is "UNINITIALIZED".
@ -107,6 +97,9 @@ set(MACHO_CURRENT_VERSION "${MACHO_COMPATIBILITY_VERSION}.${_revision}")
# saving and restoring the state of the variables.
INCLUDE(CMakePushCheckState)
# Enable the pkg-config helpers.
INCLUDE(FindPkgConfig)
# Initialize the state of the variables. This initialization is not
# necessary but this shows you what value the variables initially have.
SET(CMAKE_REQUIRED_DEFINITIONS)
@ -146,7 +139,12 @@ IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR
# either of the following two, yet neither is supported as of 3.0.2
# - check_linker_flag - does not exist
# - try_compile - does not support linker flags
IF(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
IF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-dead_strip")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-dead_strip")
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
# SunOS linker doesn't support --gc-sections
ELSE()
# Place the functions and data into separate sections, allowing the linker
# to garbage collect the unused ones.
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections")
@ -155,10 +153,7 @@ IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR
# Printing the discarded section is "too much", so enable on demand.
#SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Wl,--print-gc-sections")
#SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -Wl,--print-gc-sections")
ELSE()
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-dead_strip")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-dead_strip")
ENDIF(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
ENDIF()
ENDIF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR
CMAKE_C_COMPILER_ID MATCHES "^Clang$" AND NOT MSVC)
IF (CMAKE_C_COMPILER_ID MATCHES "^XL$")
@ -238,6 +233,7 @@ OPTION(ENABLE_ZLIB "Enable the use of the system ZLIB library if found" ON)
OPTION(ENABLE_BZip2 "Enable the use of the system BZip2 library if found" ON)
OPTION(ENABLE_LIBXML2 "Enable the use of the system libxml2 library if found" ON)
OPTION(ENABLE_EXPAT "Enable the use of the system EXPAT library if found" ON)
OPTION(ENABLE_WIN32_XMLLITE "Enable the use of the Windows XmlLite library if found" ON)
OPTION(ENABLE_PCREPOSIX "Enable the use of the system PCREPOSIX library if found" ON)
OPTION(ENABLE_PCRE2POSIX "Enable the use of the system PCRE2POSIX library if found" ON)
OPTION(ENABLE_LIBGCC "Enable the use of the system LibGCC library if found" ON)
@ -264,6 +260,10 @@ OPTION(ENABLE_TEST "Enable unit and regression tests" ON)
OPTION(ENABLE_COVERAGE "Enable code coverage (GCC only, automatically sets ENABLE_TEST to ON)" FALSE)
OPTION(ENABLE_INSTALL "Enable installing of libraries" ON)
IF(WIN32 AND MSVC)
OPTION(MSVC_USE_STATIC_CRT "Use static CRT" OFF)
ENDIF()
SET(POSIX_REGEX_LIB "AUTO" CACHE STRING "Choose what library should provide POSIX regular expression support")
SET(ENABLE_SAFESEH "AUTO" CACHE STRING "Enable use of /SAFESEH linker flag (MSVC only)")
SET(WINDOWS_VERSION "WIN10" CACHE STRING "Set Windows version to use (Windows only)")
@ -293,18 +293,6 @@ IF(WIN32)
SET(NTDDI_VERSION 0x06000100)
SET(_WIN32_WINNT 0x0600)
SET(WINVER 0x0600)
ELSEIF(WINDOWS_VERSION STREQUAL "VISTA")
SET(NTDDI_VERSION 0x06000000)
SET(_WIN32_WINNT 0x0600)
SET(WINVER 0x0600)
ELSEIF(WINDOWS_VERSION STREQUAL "WS03")
SET(NTDDI_VERSION 0x05020000)
SET(_WIN32_WINNT 0x0502)
SET(WINVER 0x0502)
ELSEIF(WINDOWS_VERSION STREQUAL "WINXP")
SET(NTDDI_VERSION 0x05010000)
SET(_WIN32_WINNT 0x0501)
SET(WINVER 0x0501)
ELSE(WINDOWS_VERSION STREQUAL "WIN10")
# Default to Windows Server 2003 API if we don't recognize the specifier
SET(NTDDI_VERSION 0x05020000)
@ -378,10 +366,12 @@ ENDMACRO (GENERATE_LIST_H)
# Generate installation rules for man pages.
#
MACRO (INSTALL_MAN __mans)
FOREACH (_man ${ARGV})
STRING(REGEX REPLACE "^.+[.]([1-9])" "\\1" _mansect ${_man})
INSTALL(FILES ${_man} DESTINATION "share/man/man${_mansect}")
ENDFOREACH (_man)
IF(ENABLE_INSTALL)
FOREACH (_man ${ARGV})
STRING(REGEX REPLACE "^.+[.]([1-9])" "\\1" _mansect ${_man})
INSTALL(FILES ${_man} DESTINATION "share/man/man${_mansect}")
ENDFOREACH (_man)
ENDIF(ENABLE_INSTALL)
ENDMACRO (INSTALL_MAN __mans)
#
# Find out what macro is needed to use libraries on Windows.
@ -606,6 +596,7 @@ IF(ENABLE_LIBB2)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBB2 DEFAULT_MSG LIBB2_LIBRARY LIBB2_INCLUDE_DIR)
ELSE(ENABLE_LIBB2)
SET(LIBB2_FOUND FALSE) # Override cached value
UNSET(LIBB2_PKGCONFIG_VERSION CACHE)
ENDIF(ENABLE_LIBB2)
IF(LIBB2_FOUND)
SET(HAVE_LIBB2 1)
@ -618,8 +609,13 @@ IF(LIBB2_FOUND)
SET(CMAKE_REQUIRED_INCLUDES ${LIBB2_INCLUDE_DIR})
CHECK_FUNCTION_EXISTS(blake2sp_init HAVE_LIBB2)
CMAKE_POP_CHECK_STATE()
pkg_check_modules(LIBB2 libb2)
IF(LIBB2_VERSION)
SET(LIBB2_PKGCONFIG_VERSION LIBB2_VERSION)
ENDIF(LIBB2_VERSION)
ELSE(LIBB2_FOUND)
SET(ARCHIVE_BLAKE2 TRUE)
UNSET(LIBB2_PKGCONFIG_VERSION CACHE)
ENDIF(LIBB2_FOUND)
#
# Find LZ4
@ -682,6 +678,7 @@ IF(ZSTD_FOUND)
SET(CMAKE_REQUIRED_INCLUDES ${ZSTD_INCLUDE_DIR})
CHECK_FUNCTION_EXISTS(ZSTD_decompressStream HAVE_LIBZSTD)
CHECK_FUNCTION_EXISTS(ZSTD_compressStream HAVE_ZSTD_compressStream)
CHECK_FUNCTION_EXISTS(ZSTD_minCLevel HAVE_ZSTD_minCLevel)
#
# TODO: test for static library.
#
@ -690,7 +687,6 @@ ENDIF(ZSTD_FOUND)
MARK_AS_ADVANCED(CLEAR ZSTD_INCLUDE_DIR)
MARK_AS_ADVANCED(CLEAR ZSTD_LIBRARY)
#
# Check headers
#
@ -784,12 +780,22 @@ IF(ENABLE_CNG)
LA_CHECK_INCLUDE_FILE("bcrypt.h" HAVE_BCRYPT_H)
IF(HAVE_BCRYPT_H)
LIST(APPEND ADDITIONAL_LIBS "bcrypt")
# bcrypt supports these algorithms on all available versions
SET(ARCHIVE_CRYPTO_MD5 1)
SET(ARCHIVE_CRYPTO_MD5_WIN 1)
SET(ARCHIVE_CRYPTO_SHA1 1)
SET(ARCHIVE_CRYPTO_SHA1_WIN 1)
SET(ARCHIVE_CRYPTO_SHA256 1)
SET(ARCHIVE_CRYPTO_SHA256_WIN 1)
SET(ARCHIVE_CRYPTO_SHA384 1)
SET(ARCHIVE_CRYPTO_SHA384_WIN 1)
SET(ARCHIVE_CRYPTO_SHA512 1)
SET(ARCHIVE_CRYPTO_SHA512_WIN 1)
ENDIF(HAVE_BCRYPT_H)
ELSE(ENABLE_CNG)
UNSET(HAVE_BCRYPT_H CACHE)
ENDIF(ENABLE_CNG)
# Following files need windows.h, so we should test it after windows.h test.
LA_CHECK_INCLUDE_FILE("wincrypt.h" HAVE_WINCRYPT_H)
LA_CHECK_INCLUDE_FILE("winioctl.h" HAVE_WINIOCTL_H)
#
@ -821,7 +827,7 @@ IF(ENABLE_MBEDTLS)
LA_CHECK_INCLUDE_FILE("mbedtls/aes.h" HAVE_MBEDTLS_AES_H)
LA_CHECK_INCLUDE_FILE("mbedtls/md.h" HAVE_MBEDTLS_MD_H)
LA_CHECK_INCLUDE_FILE("mbedtls/pkcs5.h" HAVE_MBEDTLS_PKCS5_H)
LA_CHECK_INCLUDE_FILE("mbedtls/version.h" HAVE_MBEDTLS_VERSION_H)
ENDIF(MBEDTLS_FOUND)
MARK_AS_ADVANCED(CLEAR MBEDTLS_INCLUDE_DIRS)
MARK_AS_ADVANCED(CLEAR MBEDCRYPTO_LIBRARY)
@ -844,7 +850,7 @@ IF(ENABLE_NETTLE)
LA_CHECK_INCLUDE_FILE("nettle/pbkdf2.h" HAVE_NETTLE_PBKDF2_H)
LA_CHECK_INCLUDE_FILE("nettle/ripemd160.h" HAVE_NETTLE_RIPEMD160_H)
LA_CHECK_INCLUDE_FILE("nettle/sha.h" HAVE_NETTLE_SHA_H)
LA_CHECK_INCLUDE_FILE("nettle/version.h" HAVE_NETTLE_VERSION_H)
ENDIF(NETTLE_FOUND)
MARK_AS_ADVANCED(CLEAR NETTLE_INCLUDE_DIR)
MARK_AS_ADVANCED(CLEAR NETTLE_LIBRARIES)
@ -863,6 +869,7 @@ IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
SET(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
LA_CHECK_INCLUDE_FILE("openssl/evp.h" HAVE_OPENSSL_EVP_H)
LA_CHECK_INCLUDE_FILE("openssl/opensslv.h" HAVE_OPENSSL_OPENSSLV_H)
CHECK_FUNCTION_EXISTS(PKCS5_PBKDF2_HMAC_SHA1 HAVE_PKCS5_PBKDF2_HMAC_SHA1)
ENDIF(OPENSSL_FOUND)
ELSE()
@ -881,6 +888,14 @@ IF(NOT OPENSSL_FOUND)
ENDIF(LIBMD_FOUND)
ENDIF(NOT OPENSSL_FOUND)
# libbsd for readpassphrase on Haiku
IF("${CMAKE_SYSTEM_NAME}" MATCHES "Haiku")
MESSAGE(STATUS "Adding libbsd for Haiku")
SET(CMAKE_REQUIRED_LIBRARIES "bsd")
FIND_LIBRARY(LIBBSD_LIBRARY NAMES bsd)
LIST(APPEND ADDITIONAL_LIBS ${LIBBSD_LIBRARY})
ENDIF("${CMAKE_SYSTEM_NAME}" MATCHES "Haiku")
#
# How to prove that CRYPTO functions, which have several names on various
# platforms, just see if archive_digest.c can compile and link against
@ -989,86 +1004,6 @@ main(int argc, char **argv)
ENDFOREACH(ALGORITHM ${ALGORITHMS})
ENDMACRO(CHECK_CRYPTO ALGORITHMS IMPLEMENTATION)
#
# CRYPTO functions on Windows is defined at archive_windows.c, thus we do not
# need the test what the functions can be mapped to archive_{crypto name}_init,
# archive_{crypto name}_update and archive_{crypto name}_final.
# The functions on Windows use CALG_{crypto name} macro to create a crypt object
# and then we need to know what CALG_{crypto name} macros is available to show
# ARCHIVE_CRYPTO_{crypto name}_WIN macros because Windows 2000 and earlier version
# of Windows XP do not support SHA256, SHA384 and SHA512.
#
MACRO(CHECK_CRYPTO_WIN CRYPTO_LIST)
IF(WIN32 AND NOT CYGWIN)
FOREACH(CRYPTO ${CRYPTO_LIST})
IF(NOT ARCHIVE_CRYPTO_${CRYPTO})
IF(NOT DEFINED ARCHIVE_CRYPTO_${CRYPTO}_WIN)
STRING(TOUPPER "${CRYPTO}" crypto)
SET(ALGID "")
IF ("${CRYPTO}" MATCHES "^MD5$")
SET(ALGID "CALG_MD5")
ENDIF ("${CRYPTO}" MATCHES "^MD5$")
IF ("${CRYPTO}" MATCHES "^SHA1$")
SET(ALGID "CALG_SHA1")
ENDIF ("${CRYPTO}" MATCHES "^SHA1$")
IF ("${CRYPTO}" MATCHES "^SHA256$")
SET(ALGID "CALG_SHA_256")
ENDIF ("${CRYPTO}" MATCHES "^SHA256$")
IF ("${CRYPTO}" MATCHES "^SHA384$")
SET(ALGID "CALG_SHA_384")
ENDIF ("${CRYPTO}" MATCHES "^SHA384$")
IF ("${CRYPTO}" MATCHES "^SHA512$")
SET(ALGID "CALG_SHA_512")
ENDIF ("${CRYPTO}" MATCHES "^SHA512$")
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.h.in
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/confdefs.h)
FILE(READ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/confdefs.h"
CONFDEFS_H)
SET(SOURCE "${CONFDEFS_H}
#define ${crypto}_COMPILE_TEST
#include <windows.h>
#include <wincrypt.h>
int
main(int argc, char **argv)
{
return ${ALGID};
}
")
SET(SOURCE_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_crypto_win.c")
FILE(WRITE "${SOURCE_FILE}" "${SOURCE}")
MESSAGE(STATUS "Checking support for ARCHIVE_CRYPTO_${CRYPTO}_WIN")
TRY_COMPILE(ARCHIVE_CRYPTO_${CRYPTO}_WIN
${CMAKE_BINARY_DIR}
${SOURCE_FILE}
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}/libarchive"
OUTPUT_VARIABLE OUTPUT)
IF (ARCHIVE_CRYPTO_${CRYPTO}_WIN)
MESSAGE(STATUS
"Checking support for ARCHIVE_CRYPTO_${CRYPTO}_WIN -- found")
SET(ARCHIVE_CRYPTO_${CRYPTO} 1)
ELSE (ARCHIVE_CRYPTO_${CRYPTO}_WIN)
MESSAGE(STATUS
"Checking support for ARCHIVE_CRYPTO_${CRYPTO}_WIN -- not found")
FILE(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Checking support for ARCHIVE_CRYPTO_${CRYPTO}_WIN failed with the following output:\n"
"${OUTPUT}\n"
"Source file was:\n${SOURCE}\n")
ENDIF (ARCHIVE_CRYPTO_${CRYPTO}_WIN)
ENDIF(NOT DEFINED ARCHIVE_CRYPTO_${CRYPTO}_WIN)
ENDIF(NOT ARCHIVE_CRYPTO_${CRYPTO})
ENDFOREACH(CRYPTO)
ENDIF(WIN32 AND NOT CYGWIN)
ENDMACRO(CHECK_CRYPTO_WIN CRYPTO_LIST)
#
# Find iconv
# POSIX defines the second arg as const char **
@ -1083,8 +1018,8 @@ MACRO(CHECK_ICONV LIB TRY_ICONV_CONST)
CMAKE_C_COMPILER_ID MATCHES "^Clang$")
#
# During checking iconv proto type, we should use -Werror to avoid the
# success of iconv detection with a warning which success is a miss
# detection. So this needs for all build mode(even it's a release mode).
# success of iconv detection with a warning, which would be a false
# positive. So this is needed for all build modes, even in release mode.
#
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror")
ENDIF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR
@ -1155,6 +1090,7 @@ IF(ENABLE_ICONV)
CHECK_ICONV("libiconv" "const")
CHECK_ICONV("libiconv" "")
IF (HAVE_ICONV)
SET(HAVE_LIBICONV 1)
LIST(APPEND ADDITIONAL_LIBS ${LIBICONV_PATH})
ENDIF(HAVE_ICONV)
ENDIF(NOT HAVE_ICONV AND LIBICONV_PATH)
@ -1198,6 +1134,7 @@ ELSE(ENABLE_ICONV)
# (once enabled).
UNSET(HAVE_LOCALE_CHARSET CACHE)
UNSET(HAVE_ICONV CACHE)
UNSET(HAVE_LIBICONV CACHE)
UNSET(HAVE_ICONV_libc_ CACHE)
UNSET(HAVE_ICONV_libc_const CACHE)
UNSET(HAVE_ICONV_libiconv_ CACHE)
@ -1227,6 +1164,7 @@ IF(LIBXML2_FOUND)
SET(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR})
CHECK_INCLUDE_FILES("libxml/xmlreader.h" HAVE_LIBXML_XMLREADER_H)
CHECK_INCLUDE_FILES("libxml/xmlwriter.h" HAVE_LIBXML_XMLWRITER_H)
CHECK_INCLUDE_FILES("libxml/xmlversion.h" HAVE_LIBXML_XMLVERSION_H)
# Test if a macro is needed for the library.
TRY_MACRO_FOR_LIBRARY(
"${ICONV_INCLUDE_DIR};${LIBXML2_INCLUDE_DIR}"
@ -1254,6 +1192,25 @@ ELSE(LIBXML2_FOUND)
SET(HAVE_LIBEXPAT 1)
LA_CHECK_INCLUDE_FILE("expat.h" HAVE_EXPAT_H)
CMAKE_POP_CHECK_STATE() # Restore the state of the variables
ELSE(EXPAT_FOUND)
IF(WIN32 AND ENABLE_WIN32_XMLLITE)
# Check linkage as well; versions of mingw-w64 before v11.0.0
# do not contain an import library for xmllite.
cmake_push_check_state()
SET(CMAKE_REQUIRED_LIBRARIES "xmllite" "uuid")
check_c_source_compiles("
#include <initguid.h>
#include <xmllite.h>
int main() {
return CreateXmlReader(&IID_IXmlReader, NULL, NULL);
}
" HAVE_XMLLITE_H)
cmake_pop_check_state()
IF(HAVE_XMLLITE_H)
SET(XMLLITE_FOUND TRUE)
LIST(APPEND ADDITIONAL_LIBS "xmllite" "uuid")
ENDIF()
ENDIF()
ENDIF(EXPAT_FOUND)
ENDIF(LIBXML2_FOUND)
MARK_AS_ADVANCED(CLEAR LIBXML2_INCLUDE_DIR)
@ -1455,6 +1412,8 @@ CHECK_FUNCTION_EXISTS_GLIBC(arc4random_buf HAVE_ARC4RANDOM_BUF)
CHECK_FUNCTION_EXISTS_GLIBC(chflags HAVE_CHFLAGS)
CHECK_FUNCTION_EXISTS_GLIBC(chown HAVE_CHOWN)
CHECK_FUNCTION_EXISTS_GLIBC(chroot HAVE_CHROOT)
CHECK_FUNCTION_EXISTS_GLIBC(closefrom HAVE_CLOSEFROM)
CHECK_FUNCTION_EXISTS_GLIBC(close_range HAVE_CLOSE_RANGE)
CHECK_FUNCTION_EXISTS_GLIBC(ctime_r HAVE_CTIME_R)
CHECK_FUNCTION_EXISTS_GLIBC(fchdir HAVE_FCHDIR)
CHECK_FUNCTION_EXISTS_GLIBC(fchflags HAVE_FCHFLAGS)
@ -1472,15 +1431,19 @@ CHECK_FUNCTION_EXISTS_GLIBC(ftruncate HAVE_FTRUNCATE)
CHECK_FUNCTION_EXISTS_GLIBC(futimens HAVE_FUTIMENS)
CHECK_FUNCTION_EXISTS_GLIBC(futimes HAVE_FUTIMES)
CHECK_FUNCTION_EXISTS_GLIBC(futimesat HAVE_FUTIMESAT)
CHECK_FUNCTION_EXISTS_GLIBC(getegid HAVE_GETEGID)
CHECK_FUNCTION_EXISTS_GLIBC(geteuid HAVE_GETEUID)
CHECK_FUNCTION_EXISTS_GLIBC(getgrgid_r HAVE_GETGRGID_R)
CHECK_FUNCTION_EXISTS_GLIBC(getgrnam_r HAVE_GETGRNAM_R)
CHECK_FUNCTION_EXISTS_GLIBC(getline HAVE_GETLINE)
CHECK_FUNCTION_EXISTS_GLIBC(getpid HAVE_GETPID)
CHECK_FUNCTION_EXISTS_GLIBC(getpwnam_r HAVE_GETPWNAM_R)
CHECK_FUNCTION_EXISTS_GLIBC(getpwuid_r HAVE_GETPWUID_R)
CHECK_FUNCTION_EXISTS_GLIBC(getpid HAVE_GETPID)
CHECK_FUNCTION_EXISTS_GLIBC(getresgid HAVE_GETRESGID)
CHECK_FUNCTION_EXISTS_GLIBC(getresuid HAVE_GETRESUID)
CHECK_FUNCTION_EXISTS_GLIBC(getvfsbyname HAVE_GETVFSBYNAME)
CHECK_FUNCTION_EXISTS_GLIBC(gmtime_r HAVE_GMTIME_R)
CHECK_FUNCTION_EXISTS_GLIBC(issetugid HAVE_ISSETUGID)
CHECK_FUNCTION_EXISTS_GLIBC(lchflags HAVE_LCHFLAGS)
CHECK_FUNCTION_EXISTS_GLIBC(lchmod HAVE_LCHMOD)
CHECK_FUNCTION_EXISTS_GLIBC(lchown HAVE_LCHOWN)
@ -1499,6 +1462,7 @@ CHECK_FUNCTION_EXISTS_GLIBC(nl_langinfo HAVE_NL_LANGINFO)
CHECK_FUNCTION_EXISTS_GLIBC(openat HAVE_OPENAT)
CHECK_FUNCTION_EXISTS_GLIBC(pipe HAVE_PIPE)
CHECK_FUNCTION_EXISTS_GLIBC(poll HAVE_POLL)
CHECK_FUNCTION_EXISTS_GLIBC(posix_spawn HAVE_POSIX_SPAWN)
CHECK_FUNCTION_EXISTS_GLIBC(posix_spawnp HAVE_POSIX_SPAWNP)
CHECK_FUNCTION_EXISTS_GLIBC(readlink HAVE_READLINK)
CHECK_FUNCTION_EXISTS_GLIBC(readpassphrase HAVE_READPASSPHRASE)
@ -1516,6 +1480,8 @@ CHECK_FUNCTION_EXISTS_GLIBC(strnlen HAVE_STRNLEN)
CHECK_FUNCTION_EXISTS_GLIBC(strrchr HAVE_STRRCHR)
CHECK_FUNCTION_EXISTS_GLIBC(symlink HAVE_SYMLINK)
CHECK_FUNCTION_EXISTS_GLIBC(sysconf HAVE_SYSCONF)
CHECK_FUNCTION_EXISTS_GLIBC(tcgetattr HAVE_TCGETATTR)
CHECK_FUNCTION_EXISTS_GLIBC(tcsetattr HAVE_TCSETATTR)
CHECK_FUNCTION_EXISTS_GLIBC(timegm HAVE_TIMEGM)
CHECK_FUNCTION_EXISTS_GLIBC(tzset HAVE_TZSET)
CHECK_FUNCTION_EXISTS_GLIBC(unlinkat HAVE_UNLINKAT)
@ -1525,9 +1491,9 @@ CHECK_FUNCTION_EXISTS_GLIBC(utimes HAVE_UTIMES)
CHECK_FUNCTION_EXISTS_GLIBC(utimensat HAVE_UTIMENSAT)
CHECK_FUNCTION_EXISTS_GLIBC(vfork HAVE_VFORK)
CHECK_FUNCTION_EXISTS_GLIBC(wcrtomb HAVE_WCRTOMB)
CHECK_FUNCTION_EXISTS_GLIBC(wcscmp HAVE_WCSCMP)
CHECK_FUNCTION_EXISTS_GLIBC(wcscpy HAVE_WCSCPY)
CHECK_FUNCTION_EXISTS_GLIBC(wcslen HAVE_WCSLEN)
check_symbol_exists(wcscmp wchar.h HAVE_WCSCMP)
check_symbol_exists(wcscpy wchar.h HAVE_WCSCPY)
check_symbol_exists(wcslen wchar.h HAVE_WCSLEN)
CHECK_FUNCTION_EXISTS_GLIBC(wctomb HAVE_WCTOMB)
CHECK_FUNCTION_EXISTS_GLIBC(_fseeki64 HAVE__FSEEKI64)
CHECK_FUNCTION_EXISTS_GLIBC(_get_timezone HAVE__GET_TIMEZONE)
@ -1560,12 +1526,6 @@ CHECK_C_SOURCE_COMPILES(
"#include <sys/types.h>\n#include <sys/mount.h>\nint main(void) { struct statfs s; return sizeof(s);}"
HAVE_STRUCT_STATFS)
# Make sure we have the POSIX version of readdir_r, not the
# older 2-argument version.
CHECK_C_SOURCE_COMPILES(
"#include <dirent.h>\nint main() {DIR *d = opendir(\".\"); struct dirent e,*r; return readdir_r(d,&e,&r);}"
HAVE_READDIR_R)
# dirfd can be either a function or a macro.
CHECK_C_SOURCE_COMPILES(
"#include <dirent.h>\nint main() {DIR *d = opendir(\".\"); return dirfd(d);}"
@ -1805,11 +1765,16 @@ IF(ENABLE_XATTR)
CHECK_LIBRARY_EXISTS(attr "setxattr" "" HAVE_LIBATTR)
IF(HAVE_LIBATTR)
SET(CMAKE_REQUIRED_LIBRARIES "attr")
ELSE()
pkg_check_modules(LIBATTR libattr)
IF(LIBATTR_VERSION)
SET(LIBATTR_PKGCONFIG_VERSION ${LIBATTR_VERSION})
ENDIF(LIBATTR_VERSION)
ELSE(HAVE_LIBATTR)
CHECK_LIBRARY_EXISTS(gnu "setxattr" "" HAVE_LIBATTR_GNU)
IF(HAVE_LIBATTR_GNU)
SET(CMAKE_REQUIRED_LIBRARIES "gnu")
ENDIF()
UNSET(LIBATTR_PKGCONFIG_VERSION CACHE)
ENDIF(HAVE_LIBATTR)
CHECK_SYMBOL_EXISTS(EXTATTR_NAMESPACE_USER "sys/types.h;sys/extattr.h" HAVE_DECL_EXTATTR_NAMESPACE_USER)
CHECK_SYMBOL_EXISTS(XATTR_NOFOLLOW "sys/xattr.h" HAVE_DECL_XATTR_NOFOLLOW)
@ -1927,6 +1892,12 @@ IF(ENABLE_ACL)
SET(CMAKE_REQUIRED_LIBRARIES "acl")
FIND_LIBRARY(ACL_LIBRARY NAMES acl)
LIST(APPEND ADDITIONAL_LIBS ${ACL_LIBRARY})
pkg_check_modules(LIBACL libacl)
IF(LIBACL_VERSION)
SET(LIBACL_PKGCONFIG_VERSION ${LIBACL_VERSION})
ENDIF(LIBACL_VERSION)
ELSE(HAVE_LIBACL)
UNSET(LIBACL_PKGCONFIG_VERSION CACHE)
ENDIF(HAVE_LIBACL)
CHECK_TYPE_EXISTS(acl_t "sys/types.h;sys/acl.h" HAVE_ACL_T)
@ -2066,6 +2037,12 @@ int main(void) { return ACL_SYNCHRONIZE; }" HAVE_DECL_ACL_SYNCHRONIZE)
SET(CMAKE_REQUIRED_LIBRARIES "richacl")
FIND_LIBRARY(RICHACL_LIBRARY NAMES richacl)
LIST(APPEND ADDITIONAL_LIBS ${RICHACL_LIBRARY})
pkg_check_modules(LIBRICHACL librichacl)
IF(LIBRICHACL_VERSION)
SET(LIBRICHACL_PKGCONFIG_VERSION ${LIBRICHACL_VERSION})
ENDIF(LIBRICHACL_VERSION)
ELSE(HAVE_LIBRICHACL)
UNSET(LIBRICHACL_PKGCONFIG_VERSION CACHE)
ENDIF(HAVE_LIBRICHACL)
CHECK_STRUCT_HAS_MEMBER("struct richace" e_type "sys/richacl.h"
@ -2140,8 +2117,6 @@ CHECK_CRYPTO("MD5;RMD160;SHA1;SHA256;SHA384;SHA512" OPENSSL)
# Libmd has to be probed after OpenSSL.
CHECK_CRYPTO("MD5;RMD160;SHA1;SHA256;SHA512" LIBMD)
CHECK_CRYPTO_WIN("MD5;SHA1;SHA256;SHA384;SHA512")
# Check visibility annotations
SET(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fvisibility=hidden -Werror")
@ -2165,7 +2140,7 @@ INCLUDE(CreatePkgConfigFile)
#
# Register installation of PDF documents.
#
IF(WIN32 AND NOT CYGWIN)
IF(WIN32 AND NOT CYGWIN AND ENABLE_INSTALL)
#
# On Windows platform, It's better that we install PDF documents
# on one's computer.
@ -2177,7 +2152,7 @@ IF(WIN32 AND NOT CYGWIN)
FILES_MATCHING PATTERN "*.pdf"
)
ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/doc/pdf)
ENDIF(WIN32 AND NOT CYGWIN)
ENDIF(WIN32 AND NOT CYGWIN AND ENABLE_INSTALL)
#
#
#
@ -2187,11 +2162,6 @@ IF(MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
ENDIF(MSVC)
IF(APPLE)
# CC_MD5_Init() functions are deprecated on macOS 10.15, but we want to use them
ADD_DEFINITIONS(-Wno-deprecated-declarations)
ENDIF(APPLE)
OPTION(DONT_FAIL_ON_CRC_ERROR "Ignore CRC errors during parsing (For fuzzing)" OFF)
IF(DONT_FAIL_ON_CRC_ERROR)
ADD_DEFINITIONS(-DDONT_FAIL_ON_CRC_ERROR=1)

View File

@ -20,7 +20,7 @@ the actual statements in the files are controlling.
libarchive/mtree.5
* The following source files are in the public domain:
libarchive/archive_getdate.c
libarchive/archive_parse_date.c
* The following source files are triple-licensed with the ability to choose
from CC0 1.0 Universal, OpenSSL or Apache 2.0 licenses:

View File

@ -96,61 +96,73 @@ distclean-local:
include_HEADERS= libarchive/archive.h libarchive/archive_entry.h
libarchive_la_SOURCES= \
libarchive/archive_acl.c \
noinst_HEADERS= \
libarchive/archive_acl_private.h \
libarchive/archive_check_magic.c \
libarchive/archive_cmdline.c \
libarchive/archive_cmdline_private.h \
libarchive/archive_crc32.h \
libarchive/archive_cryptor.c \
libarchive/archive_cryptor_private.h \
libarchive/archive_digest.c \
libarchive/archive_digest_private.h \
libarchive/archive_endian.h \
libarchive/archive_entry.c \
libarchive/archive_entry.h \
libarchive/archive_entry_copy_stat.c \
libarchive/archive_entry_link_resolver.c \
libarchive/archive_entry_locale.h \
libarchive/archive_entry_private.h \
libarchive/archive_hmac_private.h \
libarchive/archive_openssl_evp_private.h \
libarchive/archive_openssl_hmac_private.h \
libarchive/archive_options_private.h \
libarchive/archive_pack_dev.h \
libarchive/archive_pathmatch.h \
libarchive/archive_platform.h \
libarchive/archive_platform_acl.h \
libarchive/archive_platform_stat.h \
libarchive/archive_platform_xattr.h \
libarchive/archive_ppmd7_private.h \
libarchive/archive_ppmd8_private.h \
libarchive/archive_ppmd_private.h \
libarchive/archive_private.h \
libarchive/archive_random_private.h \
libarchive/archive_rb.h \
libarchive/archive_read_disk_private.h \
libarchive/archive_read_private.h \
libarchive/archive_string.h \
libarchive/archive_string_composition.h \
libarchive/archive_time_private.h \
libarchive/archive_write_disk_private.h \
libarchive/archive_write_private.h \
libarchive/archive_write_set_format_private.h \
libarchive/archive_xxhash.h \
libarchive/config_freebsd.h \
libarchive/filter_fork.h
libarchive_la_SOURCES= \
libarchive/archive_acl.c \
libarchive/archive_check_magic.c \
libarchive/archive_cmdline.c \
libarchive/archive_cryptor.c \
libarchive/archive_digest.c \
libarchive/archive_entry.c \
libarchive/archive_entry_copy_stat.c \
libarchive/archive_entry_link_resolver.c \
libarchive/archive_entry_sparse.c \
libarchive/archive_entry_stat.c \
libarchive/archive_entry_strmode.c \
libarchive/archive_entry_xattr.c \
libarchive/archive_getdate.c \
libarchive/archive_getdate.h \
libarchive/archive_hmac.c \
libarchive/archive_hmac_private.h \
libarchive/archive_match.c \
libarchive/archive_openssl_evp_private.h \
libarchive/archive_openssl_hmac_private.h \
libarchive/archive_options.c \
libarchive/archive_options_private.h \
libarchive/archive_pack_dev.h \
libarchive/archive_pack_dev.c \
libarchive/archive_parse_date.c \
libarchive/archive_pathmatch.c \
libarchive/archive_pathmatch.h \
libarchive/archive_platform.h \
libarchive/archive_platform_acl.h \
libarchive/archive_platform_xattr.h \
libarchive/archive_ppmd_private.h \
libarchive/archive_ppmd7.c \
libarchive/archive_ppmd7_private.h \
libarchive/archive_ppmd8.c \
libarchive/archive_ppmd8_private.h \
libarchive/archive_private.h \
libarchive/archive_random.c \
libarchive/archive_random_private.h \
libarchive/archive_rb.c \
libarchive/archive_rb.h \
libarchive/archive_read.c \
libarchive/archive_read_add_passphrase.c \
libarchive/archive_read_append_filter.c \
libarchive/archive_read_data_into_fd.c \
libarchive/archive_read_disk_entry_from_file.c \
libarchive/archive_read_disk_posix.c \
libarchive/archive_read_disk_private.h \
libarchive/archive_read_disk_set_standard_lookup.c \
libarchive/archive_read_extract.c \
libarchive/archive_read_extract2.c \
@ -158,12 +170,11 @@ libarchive_la_SOURCES= \
libarchive/archive_read_open_file.c \
libarchive/archive_read_open_filename.c \
libarchive/archive_read_open_memory.c \
libarchive/archive_read_private.h \
libarchive/archive_read_set_format.c \
libarchive/archive_read_set_options.c \
libarchive/archive_read_support_filter_all.c \
libarchive/archive_read_support_filter_bzip2.c \
libarchive/archive_read_support_filter_by_code.c \
libarchive/archive_read_support_filter_bzip2.c \
libarchive/archive_read_support_filter_compress.c \
libarchive/archive_read_support_filter_grzip.c \
libarchive/archive_read_support_filter_gzip.c \
@ -194,21 +205,12 @@ libarchive_la_SOURCES= \
libarchive/archive_read_support_format_xar.c \
libarchive/archive_read_support_format_zip.c \
libarchive/archive_string.c \
libarchive/archive_string.h \
libarchive/archive_string_composition.h \
libarchive/archive_string_sprintf.c \
libarchive/archive_time.c \
libarchive/archive_util.c \
libarchive/archive_version_details.c \
libarchive/archive_virtual.c \
libarchive/archive_write.c \
libarchive/archive_write_disk_posix.c \
libarchive/archive_write_disk_private.h \
libarchive/archive_write_disk_set_standard_lookup.c \
libarchive/archive_write_open_fd.c \
libarchive/archive_write_open_file.c \
libarchive/archive_write_open_filename.c \
libarchive/archive_write_open_memory.c \
libarchive/archive_write_private.h \
libarchive/archive_write_add_filter.c \
libarchive/archive_write_add_filter_b64encode.c \
libarchive/archive_write_add_filter_by_name.c \
@ -224,6 +226,12 @@ libarchive_la_SOURCES= \
libarchive/archive_write_add_filter_uuencode.c \
libarchive/archive_write_add_filter_xz.c \
libarchive/archive_write_add_filter_zstd.c \
libarchive/archive_write_disk_posix.c \
libarchive/archive_write_disk_set_standard_lookup.c \
libarchive/archive_write_open_fd.c \
libarchive/archive_write_open_file.c \
libarchive/archive_write_open_filename.c \
libarchive/archive_write_open_memory.c \
libarchive/archive_write_set_format.c \
libarchive/archive_write_set_format_7zip.c \
libarchive/archive_write_set_format_ar.c \
@ -233,59 +241,54 @@ libarchive_la_SOURCES= \
libarchive/archive_write_set_format_cpio_newc.c \
libarchive/archive_write_set_format_cpio_odc.c \
libarchive/archive_write_set_format_filter_by_ext.c \
libarchive/archive_write_set_format_gnutar.c \
libarchive/archive_write_set_format_iso9660.c \
libarchive/archive_write_set_format_mtree.c \
libarchive/archive_write_set_format_pax.c \
libarchive/archive_write_set_format_private.h \
libarchive/archive_write_set_format_raw.c \
libarchive/archive_write_set_format_shar.c \
libarchive/archive_write_set_format_ustar.c \
libarchive/archive_write_set_format_v7tar.c \
libarchive/archive_write_set_format_gnutar.c \
libarchive/archive_write_set_format_warc.c \
libarchive/archive_write_set_format_xar.c \
libarchive/archive_write_set_format_zip.c \
libarchive/archive_write_set_options.c \
libarchive/archive_write_set_passphrase.c \
libarchive/archive_xxhash.h \
libarchive/config_freebsd.h \
libarchive/filter_fork_posix.c \
libarchive/filter_fork.h \
libarchive/xxhash.c
if INC_WINDOWS_FILES
noinst_HEADERS+= \
libarchive/archive_windows.h
libarchive_la_SOURCES+= \
libarchive/archive_entry_copy_bhfi.c \
libarchive/archive_read_disk_windows.c \
libarchive/archive_windows.h \
libarchive/archive_windows.c \
libarchive/archive_write_disk_windows.c \
libarchive/filter_fork_windows.c
endif
if INC_BLAKE2
libarchive_la_SOURCES+= \
noinst_HEADERS+= \
libarchive/archive_blake2.h \
libarchive/archive_blake2_impl.h \
libarchive/archive_blake2_impl.h
libarchive_la_SOURCES+= \
libarchive/archive_blake2s_ref.c \
libarchive/archive_blake2sp_ref.c
endif
if INC_LINUX_ACL
libarchive_la_SOURCES+= libarchive/archive_disk_acl_linux.c
else
endif
if INC_SUNOS_ACL
libarchive_la_SOURCES+= libarchive/archive_disk_acl_sunos.c
else
endif
if INC_DARWIN_ACL
libarchive_la_SOURCES+= libarchive/archive_disk_acl_darwin.c
else
endif
if INC_FREEBSD_ACL
libarchive_la_SOURCES+= libarchive/archive_disk_acl_freebsd.c
endif
endif
endif
endif
# -no-undefined marks that libarchive doesn't rely on symbols
# defined in the application. This is mandatory for cygwin.
@ -349,22 +352,25 @@ pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = build/pkgconfig/libarchive.pc
# Sources needed by all test programs
noinst_HEADERS+= \
test_utils/test_common.h \
test_utils/test_utils.h
test_utils_SOURCES= \
test_utils/test_utils.c \
test_utils/test_utils.h \
test_utils/test_main.c \
test_utils/test_common.h
test_utils/test_utils.c
#
#
# libarchive_test program
#
#
noinst_HEADERS+= \
libarchive/test/test.h
libarchive_test_SOURCES= \
$(libarchive_la_SOURCES) \
$(test_utils_SOURCES) \
libarchive/test/read_open_memory.c \
libarchive/test/test.h \
libarchive/test/test_7zip_filename_encoding.c \
libarchive/test/test_acl_nfs4.c \
libarchive/test/test_acl_pax.c \
libarchive/test/test_acl_platform_nfs4.c \
@ -376,10 +382,10 @@ libarchive_test_SOURCES= \
libarchive/test/test_archive_clear_error.c \
libarchive/test/test_archive_cmdline.c \
libarchive/test/test_archive_digest.c \
libarchive/test/test_archive_getdate.c \
libarchive/test/test_archive_match_owner.c \
libarchive/test/test_archive_match_path.c \
libarchive/test/test_archive_match_time.c \
libarchive/test/test_archive_parse_date.c \
libarchive/test/test_archive_pathmatch.c \
libarchive/test/test_archive_read.c \
libarchive/test/test_archive_read_add_passphrase.c \
@ -410,6 +416,7 @@ libarchive_test_SOURCES= \
libarchive/test/test_compat_bzip2.c \
libarchive/test/test_compat_cpio.c \
libarchive/test/test_compat_gtar.c \
libarchive/test/test_compat_gtar_large.c \
libarchive/test/test_compat_gzip.c \
libarchive/test/test_compat_lz4.c \
libarchive/test/test_compat_lzip.c \
@ -450,6 +457,7 @@ libarchive_test_SOURCES= \
libarchive/test/test_read_file_nonexistent.c \
libarchive/test/test_read_filter_compress.c \
libarchive/test/test_read_filter_grzip.c \
libarchive/test/test_read_filter_gzip_recursive.c \
libarchive/test/test_read_filter_lrzip.c \
libarchive/test/test_read_filter_lzop.c \
libarchive/test/test_read_filter_lzop_multiple_parts.c \
@ -461,6 +469,7 @@ libarchive_test_SOURCES= \
libarchive/test/test_read_format_7zip_encryption_data.c \
libarchive/test/test_read_format_7zip_encryption_partially.c \
libarchive/test/test_read_format_7zip_encryption_header.c \
libarchive/test/test_read_format_7zip_issue2765.c \
libarchive/test/test_read_format_7zip_malformed.c \
libarchive/test/test_read_format_7zip_packinfo_digests.c \
libarchive/test/test_read_format_ar.c \
@ -486,7 +495,9 @@ libarchive_test_SOURCES= \
libarchive/test/test_read_format_gtar_filename.c \
libarchive/test/test_read_format_gtar_gz.c \
libarchive/test/test_read_format_gtar_lzma.c \
libarchive/test/test_read_format_gtar_redundant_L.c \
libarchive/test/test_read_format_gtar_sparse.c \
libarchive/test/test_read_format_gtar_sparse_length.c \
libarchive/test/test_read_format_gtar_sparse_skip_entry.c \
libarchive/test/test_read_format_huge_rpm.c \
libarchive/test/test_read_format_iso_Z.c \
@ -509,21 +520,27 @@ libarchive_test_SOURCES= \
libarchive/test/test_read_format_mtree_crash747.c \
libarchive/test/test_read_format_pax_bz2.c \
libarchive/test/test_read_format_rar.c \
libarchive/test/test_read_format_rar_encryption.c \
libarchive/test/test_read_format_rar_encryption_data.c \
libarchive/test/test_read_format_rar_encryption_partially.c \
libarchive/test/test_read_format_rar_encryption_header.c \
libarchive/test/test_read_format_rar_filter.c \
libarchive/test/test_read_format_rar_invalid1.c \
libarchive/test/test_read_format_rar_overflow.c \
libarchive/test/test_read_format_rar5.c \
libarchive/test/test_read_format_raw.c \
libarchive/test/test_read_format_tar.c \
libarchive/test/test_read_format_tar_V_negative_size.c \
libarchive/test/test_read_format_tar_concatenated.c \
libarchive/test/test_read_format_tar_empty_pax.c \
libarchive/test/test_read_format_tar_empty_filename.c \
libarchive/test/test_read_format_tar_empty_with_gnulabel.c \
libarchive/test/test_read_format_tar_filename.c \
libarchive/test/test_read_format_tar_invalid_pax_size.c \
libarchive/test/test_read_format_tar_mac_metadata.c \
libarchive/test/test_read_format_tar_pax_g_large.c \
libarchive/test/test_read_format_tar_pax_large_attr.c \
libarchive/test/test_read_format_tar_pax_negative_time.c \
libarchive/test/test_read_format_tbz.c \
libarchive/test/test_read_format_tgz.c \
libarchive/test/test_read_format_tlz.c \
@ -556,6 +573,7 @@ libarchive_test_SOURCES= \
libarchive/test/test_read_format_zip_zip64.c \
libarchive/test/test_read_format_zip_with_invalid_traditional_eocd.c \
libarchive/test/test_read_large.c \
libarchive/test/test_read_pax_empty_val_no_nl.c \
libarchive/test/test_read_pax_xattr_rht_security_selinux.c \
libarchive/test/test_read_pax_xattr_schily.c \
libarchive/test/test_read_pax_truncated.c \
@ -582,6 +600,7 @@ libarchive_test_SOURCES= \
libarchive/test/test_write_disk_no_hfs_compression.c \
libarchive/test/test_write_disk_perms.c \
libarchive/test/test_write_disk_secure.c \
libarchive/test/test_write_disk_secure_noabsolutepaths.c \
libarchive/test/test_write_disk_secure744.c \
libarchive/test/test_write_disk_secure745.c \
libarchive/test/test_write_disk_secure746.c \
@ -623,6 +642,7 @@ libarchive_test_SOURCES= \
libarchive/test/test_write_format_mtree_classic_indent.c\
libarchive/test/test_write_format_mtree_fflags.c \
libarchive/test/test_write_format_mtree_no_separator.c \
libarchive/test/test_write_format_mtree_preset_digests.c \
libarchive/test/test_write_format_mtree_quoted_filename.c\
libarchive/test/test_write_format_pax.c \
libarchive/test/test_write_format_raw.c \
@ -640,6 +660,9 @@ libarchive_test_SOURCES= \
libarchive/test/test_write_format_zip.c \
libarchive/test/test_write_format_zip64_stream.c \
libarchive/test/test_write_format_zip_compression_store.c \
libarchive/test/test_write_format_zip_compression_zstd.c \
libarchive/test/test_write_format_zip_compression_bzip2.c \
libarchive/test/test_write_format_zip_compression_lzmaxz.c \
libarchive/test/test_write_format_zip_empty.c \
libarchive/test/test_write_format_zip_empty_zip64.c \
libarchive/test/test_write_format_zip_entry_size_unset.c \
@ -653,7 +676,6 @@ libarchive_test_SOURCES= \
libarchive/test/test_write_read_format_zip.c \
libarchive/test/test_xattr_platform.c \
libarchive/test/test_zip_filename_encoding.c
libarchive_test_CPPFLAGS= \
-I$(top_srcdir)/libarchive \
-I$(top_srcdir)/libarchive/test \
@ -666,9 +688,9 @@ libarchive_test_LDADD= $(LTLIBICONV)
# The "list.h" file just lists all of the tests defined in all of the sources.
# Building it automatically provides a sanity-check on libarchive_test_SOURCES
# above.
libarchive/test/list.h: Makefile
libarchive/test/list.h: $(libarchive_test_SOURCES)
$(MKDIR_P) libarchive/test
cat $(top_srcdir)/libarchive/test/test_*.c | grep '^DEFINE_TEST' > libarchive/test/list.h
grep -h '^DEFINE_TEST(' $^ | LC_COLLATE=C sort > $@
libarchive_TESTS_ENVIRONMENT= LIBARCHIVE_TEST_FILES=`cd $(top_srcdir);/bin/pwd`/libarchive/test LRZIP=NOCONFIG
@ -688,6 +710,7 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_compat_lz4_2.tar.lz4.uu \
libarchive/test/test_compat_lz4_3.tar.lz4.uu \
libarchive/test/test_compat_lz4_B4.tar.lz4.uu \
libarchive/test/test_compat_lz4_skippable_frames_B4.tar.lz4.uu \
libarchive/test/test_compat_lz4_B4BD.tar.lz4.uu \
libarchive/test/test_compat_lz4_B4BDBX.tar.lz4.uu \
libarchive/test/test_compat_lz4_B5.tar.lz4.uu \
@ -756,6 +779,7 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_rar_multivolume_uncompressed_files.part09.rar.uu \
libarchive/test/test_rar_multivolume_uncompressed_files.part10.rar.uu \
libarchive/test/test_read_filter_grzip.tar.grz.uu \
libarchive/test/test_read_filter_gzip_recursive.gz.uu \
libarchive/test/test_read_filter_lrzip.tar.lrz.uu \
libarchive/test/test_read_filter_lzop.tar.lzo.uu \
libarchive/test/test_read_filter_lzop_multiple_parts.tar.lzo.uu \
@ -782,6 +806,7 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_read_format_7zip_copy_2.7z.uu \
libarchive/test/test_read_format_7zip_deflate.7z.uu \
libarchive/test/test_read_format_7zip_deflate_arm64.7z.uu \
libarchive/test/test_read_format_7zip_deflate_powerpc.7z.uu \
libarchive/test/test_read_format_7zip_delta_lzma1.7z.uu \
libarchive/test/test_read_format_7zip_delta4_lzma1.7z.uu \
libarchive/test/test_read_format_7zip_delta_lzma2.7z.uu \
@ -792,22 +817,30 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_read_format_7zip_encryption_header.7z.uu \
libarchive/test/test_read_format_7zip_encryption_partially.7z.uu \
libarchive/test/test_read_format_7zip_extract_second.7z.uu \
libarchive/test/test_read_format_7zip_issue2765.7z.uu \
libarchive/test/test_read_format_7zip_lzma1.7z.uu \
libarchive/test/test_read_format_7zip_lzma1_2.7z.uu \
libarchive/test/test_read_format_7zip_lzma1_lzma2.7z.uu \
libarchive/test/test_read_format_7zip_lzma2.7z.uu \
libarchive/test/test_read_format_7zip_lzma2_arm64.7z.uu \
libarchive/test/test_read_format_7zip_lzma2_arm.7z.uu \
libarchive/test/test_read_format_7zip_lzma2_powerpc.7z.uu \
libarchive/test/test_read_format_7zip_lzma2_riscv.7z.uu \
libarchive/test/test_read_format_7zip_lzma2_sparc.7z.uu \
libarchive/test/test_read_format_7zip_malformed.7z.uu \
libarchive/test/test_read_format_7zip_malformed2.7z.uu \
libarchive/test/test_read_format_7zip_packinfo_digests.7z.uu \
libarchive/test/test_read_format_7zip_ppmd.7z.uu \
libarchive/test/test_read_format_7zip_sfx_elf.elf.uu \
libarchive/test/test_read_format_7zip_sfx_modified_pe.exe.uu \
libarchive/test/test_read_format_7zip_sfx_pe.exe.uu \
libarchive/test/test_read_format_7zip_solid_zstd.7z.uu \
libarchive/test/test_read_format_7zip_symbolic_name.7z.uu \
libarchive/test/test_read_format_7zip_win_attrib.7z.uu \
libarchive/test/test_read_format_7zip_zstd_arm.7z.uu \
libarchive/test/test_read_format_7zip_zstd_bcj.7z.uu \
libarchive/test/test_read_format_7zip_zstd_nobcj.7z.uu \
libarchive/test/test_read_format_7zip_zstd_sparc.7z.uu \
libarchive/test/test_read_format_7zip_zstd.7z.uu \
libarchive/test/test_read_format_ar.ar.uu \
libarchive/test/test_read_format_cab_1.cab.uu \
@ -826,12 +859,14 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_read_format_gtar_filename_cp866.tar.Z.uu \
libarchive/test/test_read_format_gtar_filename_eucjp.tar.Z.uu \
libarchive/test/test_read_format_gtar_filename_koi8r.tar.Z.uu \
libarchive/test/test_read_format_gtar_redundant_L.tar.Z.uu \
libarchive/test/test_read_format_gtar_sparse_1_13.tar.uu \
libarchive/test/test_read_format_gtar_sparse_1_17.tar.uu \
libarchive/test/test_read_format_gtar_sparse_1_17_posix00.tar.uu \
libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tar.uu \
libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tar.uu \
libarchive/test/test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu \
libarchive/test/test_read_format_gtar_sparse_length.tar.Z.uu \
libarchive/test/test_read_format_gtar_sparse_skip_entry.tar.Z.uu \
libarchive/test/test_read_format_huge_rpm.rpm.uu \
libarchive/test/test_read_format_iso.iso.Z.uu \
@ -870,6 +905,7 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_read_format_rar_encryption_data.rar.uu \
libarchive/test/test_read_format_rar_encryption_header.rar.uu \
libarchive/test/test_read_format_rar_encryption_partially.rar.uu \
libarchive/test/test_read_format_rar_endarc_huge.rar.uu \
libarchive/test/test_read_format_rar_filter.rar.uu \
libarchive/test/test_read_format_rar_invalid1.rar.uu \
libarchive/test/test_read_format_rar_multi_lzss_blocks.rar.uu \
@ -877,14 +913,28 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_read_format_rar_multivolume.part0002.rar.uu \
libarchive/test/test_read_format_rar_multivolume.part0003.rar.uu \
libarchive/test/test_read_format_rar_multivolume.part0004.rar.uu \
libarchive/test/test_read_format_rar_newsub_huge.rar.uu \
libarchive/test/test_read_format_rar_noeof.rar.uu \
libarchive/test/test_read_format_rar_overflow.rar.uu \
libarchive/test/test_read_format_rar_ppmd_lzss_conversion.rar.uu \
libarchive/test/test_read_format_rar_ppmd_use_after_free.rar.uu \
libarchive/test/test_read_format_rar_ppmd_use_after_free2.rar.uu \
libarchive/test/test_read_format_rar_sfx.exe.uu \
libarchive/test/test_read_format_rar_subblock.rar.uu \
libarchive/test/test_read_format_rar_symlink_huge.rar.uu \
libarchive/test/test_read_format_rar_unicode.rar.uu \
libarchive/test/test_read_format_rar_windows.rar.uu \
libarchive/test/test_read_format_rar4_encrypted.rar.uu \
libarchive/test/test_read_format_rar4_encrypted_filenames.rar.uu \
libarchive/test/test_read_format_rar4_solid_encrypted.rar.uu \
libarchive/test/test_read_format_rar4_solid_encrypted_filenames.rar.uu \
libarchive/test/test_read_format_rar5_only_crypt_exfld.rar.uu \
libarchive/test/test_read_format_rar5_unsupported_exfld.rar.uu \
libarchive/test/test_read_format_rar5_invalid_hash_valid_htime_exfld.rar.uu \
libarchive/test/test_read_format_rar5_encrypted.rar.uu \
libarchive/test/test_read_format_rar5_encrypted_filenames.rar.uu \
libarchive/test/test_read_format_rar5_solid_encrypted.rar.uu \
libarchive/test/test_read_format_rar5_solid_encrypted_filenames.rar.uu \
libarchive/test/test_read_format_rar5_arm.rar.uu \
libarchive/test/test_read_format_rar5_blake2.rar.uu \
libarchive/test/test_read_format_rar5_compressed.rar.uu \
@ -912,6 +962,7 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_read_format_rar5_multiple_files.rar.uu \
libarchive/test/test_read_format_rar5_multiple_files_solid.rar.uu \
libarchive/test/test_read_format_rar5_nonempty_dir_stream.rar.uu \
libarchive/test/test_read_format_rar5_dirdata.rar.uu \
libarchive/test/test_read_format_rar5_owner.rar.uu \
libarchive/test/test_read_format_rar5_readtables_overflow.rar.uu \
libarchive/test/test_read_format_rar5_sfx.exe.uu \
@ -920,6 +971,7 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_read_format_rar5_stored_manyfiles.rar.uu \
libarchive/test/test_read_format_rar5_symlink.rar.uu \
libarchive/test/test_read_format_rar5_truncated_huff.rar.uu \
libarchive/test/test_read_format_rar5_unicode.rar.uu \
libarchive/test/test_read_format_rar5_win32.rar.uu \
libarchive/test/test_read_format_rar5_arm_filter_on_window_boundary.rar.uu \
libarchive/test/test_read_format_rar5_different_winsize_on_merge.rar.uu \
@ -932,17 +984,22 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_read_format_raw.data.gz.uu \
libarchive/test/test_read_format_raw.data.Z.uu \
libarchive/test/test_read_format_raw.data.uu \
libarchive/test/test_read_format_tar_V_negative_size.tar.uu \
libarchive/test/test_read_format_tar_concatenated.tar.uu \
libarchive/test/test_read_format_tar_empty_filename.tar.uu \
libarchive/test/test_read_format_tar_empty_with_gnulabel.tar.uu \
libarchive/test/test_read_format_tar_empty_pax.tar.Z.uu \
libarchive/test/test_read_format_tar_filename_koi8r.tar.Z.uu \
libarchive/test/test_read_format_tar_invalid_pax_size.tar.uu \
libarchive/test/test_read_format_tar_mac_metadata_1.tar.uu \
libarchive/test/test_read_format_tar_pax_g_large.tar.uu \
libarchive/test/test_read_format_tar_pax_large_attr.tar.Z.uu \
libarchive/test/test_read_format_tar_pax_negative_time.tar.uu \
libarchive/test/test_read_format_ustar_filename_cp866.tar.Z.uu \
libarchive/test/test_read_format_ustar_filename_eucjp.tar.Z.uu \
libarchive/test/test_read_format_ustar_filename_koi8r.tar.Z.uu \
libarchive/test/test_read_format_warc.warc.uu \
libarchive/test/test_read_format_warc_incomplete.warc.uu \
libarchive/test/test_read_format_xar_doublelink.xar.uu \
libarchive/test/test_read_format_xar_duplicate_filename_node.xar.uu \
libarchive/test/test_read_format_zip.zip.uu \
@ -1002,6 +1059,7 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_read_large_splitted_rar_ac.uu \
libarchive/test/test_read_large_splitted_rar_ad.uu \
libarchive/test/test_read_large_splitted_rar_ae.uu \
libarchive/test/test_read_pax_empty_val_no_nl.tar.uu \
libarchive/test/test_read_pax_xattr_rht_security_selinux.tar.uu \
libarchive/test/test_read_pax_xattr_schily.tar.uu \
libarchive/test/test_read_splitted_rar_aa.uu \
@ -1013,6 +1071,7 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_splitted_rar_seek_support_ab.uu \
libarchive/test/test_splitted_rar_seek_support_ac.uu \
libarchive/test/test_write_disk_appledouble.cpio.gz.uu \
libarchive/test/test_write_disk_appledouble_zip.zip.uu \
libarchive/test/test_write_disk_hfs_compression.tgz.uu \
libarchive/test/test_write_disk_mac_metadata.tar.gz.uu \
libarchive/test/test_write_disk_no_hfs_compression.tgz.uu \
@ -1022,14 +1081,15 @@ libarchive_test_EXTRA_DIST=\
#
# Common code for libarchive frontends (cpio, tar)
#
libarchive_fe_la_SOURCES= \
libarchive_fe/err.c \
libarchive_fe/err.h \
noinst_HEADERS+= \
libarchive_fe/lafe_err.h \
libarchive_fe/lafe_platform.h \
libarchive_fe/line_reader.c \
libarchive_fe/line_reader.h \
libarchive_fe/passphrase.c \
libarchive_fe/passphrase.h
libarchive_fe_la_SOURCES= \
libarchive_fe/lafe_err.c \
libarchive_fe/line_reader.c \
libarchive_fe/passphrase.c
libarchive_fe_la_CPPFLAGS= -I$(top_srcdir)/libarchive
#
@ -1038,21 +1098,23 @@ libarchive_fe_la_CPPFLAGS= -I$(top_srcdir)/libarchive
#
#
noinst_HEADERS+= \
tar/bsdtar.h \
tar/bsdtar_platform.h
bsdtar_SOURCES= \
tar/bsdtar.c \
tar/bsdtar.h \
tar/bsdtar_platform.h \
tar/cmdline.c \
tar/creation_set.c \
tar/read.c \
tar/subst.c \
tar/util.c \
tar/write.c
tar/bsdtar.c \
tar/cmdline.c \
tar/creation_set.c \
tar/read.c \
tar/subst.c \
tar/util.c \
tar/write.c
if INC_WINDOWS_FILES
noinst_HEADERS+= \
tar/bsdtar_windows.h
bsdtar_SOURCES+= \
tar/bsdtar_windows.h \
tar/bsdtar_windows.c
tar/bsdtar_windows.c
endif
bsdtar_DEPENDENCIES= libarchive.la libarchive_fe.la
@ -1089,12 +1151,15 @@ endif
# bsdtar_test
#
noinst_HEADERS+= \
tar/test/test.h
bsdtar_test_SOURCES= \
$(test_utils_SOURCES) \
tar/test/test.h \
tar/test/test_0.c \
tar/test/test_basic.c \
tar/test/test_copy.c \
tar/test/test_crlf_mtree.c \
tar/test/test_empty_mtree.c \
tar/test/test_extract_tar_Z.c \
tar/test/test_extract_tar_bz2.c \
@ -1110,12 +1175,14 @@ bsdtar_test_SOURCES= \
tar/test/test_format_newc.c \
tar/test/test_help.c \
tar/test/test_leading_slash.c \
tar/test/test_list_item.c \
tar/test/test_missing_file.c \
tar/test/test_option_C_mtree.c \
tar/test/test_option_C_upper.c \
tar/test/test_option_H_upper.c \
tar/test/test_option_L_upper.c \
tar/test/test_option_O_upper.c \
tar/test/test_option_P_upper.c \
tar/test/test_option_T_upper.c \
tar/test/test_option_U_upper.c \
tar/test/test_option_X_upper.c \
@ -1137,6 +1204,7 @@ bsdtar_test_SOURCES= \
tar/test/test_option_lz4.c \
tar/test/test_option_lzma.c \
tar/test/test_option_lzop.c \
tar/test/test_option_mtime.c \
tar/test/test_option_n.c \
tar/test/test_option_newer_than.c \
tar/test/test_option_nodump.c \
@ -1168,9 +1236,9 @@ bsdtar_test_CPPFLAGS=\
-I$(top_builddir)/tar/test \
$(PLATFORMCPPFLAGS)
tar/test/list.h: Makefile
tar/test/list.h: $(bsdtar_test_SOURCES)
$(MKDIR_P) tar/test
cat $(top_srcdir)/tar/test/test_*.c | grep '^DEFINE_TEST' > tar/test/list.h
grep -h '^DEFINE_TEST(' $^ | LC_COLLATE=C sort > $@
if BUILD_BSDTAR
bsdtar_test_programs= bsdtar_test
@ -1194,6 +1262,7 @@ bsdtar_test_EXTRA_DIST= \
tar/test/test_extract.tar.lzo.uu \
tar/test/test_extract.tar.xz.uu \
tar/test/test_leading_slash.tar.uu \
tar/test/test_list_item.tar.uu \
tar/test/test_option_keep_newer_files.tar.Z.uu \
tar/test/test_option_passphrase.zip.uu \
tar/test/test_option_s.tar.Z.uu \
@ -1210,16 +1279,18 @@ bsdtar_test_EXTRA_DIST= \
#
#
noinst_HEADERS+= \
cpio/cpio.h \
cpio/cpio_platform.h
bsdcpio_SOURCES= \
cpio/cmdline.c \
cpio/cpio.c \
cpio/cpio.h \
cpio/cpio_platform.h
cpio/cmdline.c \
cpio/cpio.c
if INC_WINDOWS_FILES
noinst_HEADERS+= \
cpio/cpio_windows.h
bsdcpio_SOURCES+= \
cpio/cpio_windows.h \
cpio/cpio_windows.c
cpio/cpio_windows.c
endif
bsdcpio_DEPENDENCIES = libarchive.la libarchive_fe.la
@ -1258,14 +1329,16 @@ endif
# bsdcpio_test
#
noinst_HEADERS+= \
cpio/test/test.h
bsdcpio_test_SOURCES= \
$(test_utils_SOURCES) \
cpio/cmdline.c \
cpio/test/test.h \
cpio/test/test_0.c \
cpio/test/test_basic.c \
cpio/test/test_cmdline.c \
cpio/test/test_extract_cpio_Z.c \
cpio/test/test_extract_cpio_absolute_paths.c \
cpio/test/test_extract_cpio_bz2.c \
cpio/test/test_extract_cpio_grz.c \
cpio/test/test_extract_cpio_gz.c \
@ -1319,9 +1392,9 @@ bsdcpio_test_CPPFLAGS= \
$(PLATFORMCPPFLAGS)
bsdcpio_test_LDADD=libarchive_fe.la
cpio/test/list.h: Makefile
cpio/test/list.h: $(bsdcpio_test_SOURCES)
$(MKDIR_P) cpio/test
cat $(top_srcdir)/cpio/test/test_*.c | grep '^DEFINE_TEST' > cpio/test/list.h
grep -h '^DEFINE_TEST(' $^ | LC_COLLATE=C sort > $@
if BUILD_BSDCPIO
bsdcpio_test_programs= bsdcpio_test
@ -1366,13 +1439,15 @@ bsdcpio_test_EXTRA_DIST= \
#
#
noinst_HEADERS+= \
cat/bsdcat.h \
cat/bsdcat_platform.h
bsdcat_SOURCES= \
cat/bsdcat.c \
cat/bsdcat.h \
cat/bsdcat_platform.h \
cat/cmdline.c
cat/bsdcat.c \
cat/cmdline.c
if INC_WINDOWS_FILES
noinst_HEADERS+=
bsdcat_SOURCES+=
endif
@ -1409,9 +1484,10 @@ endif
# bsdcat_test
#
noinst_HEADERS+= \
cat/test/test.h
bsdcat_test_SOURCES= \
$(test_utils_SOURCES) \
cat/test/test.h \
cat/test/test_0.c \
cat/test/test_empty_gz.c \
cat/test/test_empty_lz4.c \
@ -1439,9 +1515,9 @@ bsdcat_test_CPPFLAGS= \
$(PLATFORMCPPFLAGS)
bsdcat_test_LDADD=libarchive_fe.la
cat/test/list.h: Makefile
cat/test/list.h: $(bsdcat_test_SOURCES)
$(MKDIR_P) cat/test
cat $(top_srcdir)/cat/test/test_*.c | grep '^DEFINE_TEST' > cat/test/list.h
grep -h '^DEFINE_TEST(' $^ | LC_COLLATE=C sort > $@
if BUILD_BSDCAT
bsdcat_test_programs= bsdcat_test
@ -1472,15 +1548,18 @@ bsdcat_test_EXTRA_DIST= \
#
#
noinst_HEADERS+= \
unzip/bsdunzip.h \
unzip/bsdunzip_platform.h \
unzip/la_getline.h \
unzip/la_queue.h
bsdunzip_SOURCES= \
unzip/bsdunzip.c \
unzip/bsdunzip.h \
unzip/bsdunzip_platform.h \
unzip/cmdline.c \
unzip/la_getline.c \
unzip/la_queue.h
unzip/bsdunzip.c \
unzip/cmdline.c \
unzip/la_getline.c
if INC_WINDOWS_FILES
noinst_HEADERS+=
bsdunzip_SOURCES+=
endif
@ -1517,9 +1596,10 @@ endif
# bsdunzip_test
#
noinst_HEADERS+= \
unzip/test/test.h
bsdunzip_test_SOURCES= \
$(test_utils_SOURCES) \
unzip/test/test.h \
unzip/test/test_0.c \
unzip/test/test_basic.c \
unzip/test/test_doubledash.c \
@ -1550,9 +1630,9 @@ bsdunzip_test_CPPFLAGS= \
$(PLATFORMCPPFLAGS)
bsdunzip_test_LDADD=libarchive_fe.la
unzip/test/list.h: Makefile
unzip/test/list.h: $(bsdunzip_test_SOURCES)
$(MKDIR_P) unzip/test
cat $(top_srcdir)/unzip/test/test_*.c | grep '^DEFINE_TEST' > unzip/test/list.h
grep -h '^DEFINE_TEST(' $^ | LC_COLLATE=C sort > $@
if BUILD_BSDUNZIP
bsdunzip_test_programs= bsdunzip_test

10
NEWS
View File

@ -1,3 +1,13 @@
May 20, 2025: libarchive 3.8.0 released
Mar 30, 2025: libarchive 3.7.9 released
Mar 20, 2025: libarchive 3.7.8 released
Oct 13, 2024: libarchive 3.7.7 released
Sep 23, 2024: libarchive 3.7.6 released
Sep 13, 2024: libarchive 3.7.5 released
Apr 26, 2024: libarchive 3.7.4 released

View File

@ -85,13 +85,14 @@ Currently, the library automatically detects and reads the following formats:
* PWB binary cpio
* ISO9660 CD-ROM images (with optional Rockridge or Joliet extensions)
* ZIP archives (with uncompressed or "deflate" compressed entries, including support for encrypted Zip archives)
* ZIPX archives (with support for bzip2, ppmd8, lzma and xz compressed entries)
* ZIPX archives (with support for bzip2, zstd, ppmd8, lzma and xz compressed entries)
* GNU and BSD 'ar' archives
* 'mtree' format
* 7-Zip archives (including archives that use zstandard compression)
* Microsoft CAB format
* LHA and LZH archives
* RAR and RAR 5.0 archives (with some limitations due to RAR's proprietary status)
* WARC archives
* XAR archives
The library also detects and handles any of the following before evaluating the archive:
@ -120,15 +121,18 @@ The library can create archives in any of the following formats:
* PWB binary cpio
* shar archives
* ZIP archives (with uncompressed or "deflate" compressed entries)
* ZIPX archives (with bzip2, zstd, lzma or xz compressed entries)
* GNU and BSD 'ar' archives
* 'mtree' format
* ISO9660 format
* 7-Zip archives
* 7-Zip archives (including archives that use zstandard compression)
* WARC archives
* XAR archives
When creating archives, the result can be filtered with any of the following:
* uuencode
* base64
* gzip compression
* bzip2 compression
* compress/LZW compression
@ -187,7 +191,7 @@ questions we are asked about libarchive:
libraries. This also reduces the size of statically-linked
binaries in environments where that matters.
* The library is generally _thread safe_ depending on the platform:
* The library is generally _thread-safe_ depending on the platform:
it does not define any global variables of its own. However, some
platforms do not provide fully thread-safe versions of key C library
functions. On those platforms, libarchive will use the non-thread-safe
@ -210,7 +214,7 @@ questions we are asked about libarchive:
multiple threads. Of course, those modules are completely
optional and you can use the rest of libarchive without them.
* The library is _not_ thread aware, however. It does no locking
* The library is _not_ thread-aware, however. It does no locking
or thread management of any kind. If you create a libarchive
object and need to access it from multiple threads, you will
need to provide your own locking.
@ -241,4 +245,3 @@ questions we are asked about libarchive:
appropriate. It has many advantages over other tar formats
(including the legacy GNU tar format) and is widely supported by
current tar implementations.

View File

@ -16,4 +16,4 @@ Please provide the following information in your report:
- How to reproduce the issue
This project is maintained by volunteers on a reasonable-effort basis. As such, we ask
that you give me 90 days to work on a fix before public exposure.
that you give us 90 days to work on a fix before public exposure.

View File

@ -1,7 +1,7 @@
#!/bin/sh
set -eu
PATH=/usr/local/gnu-autotools/bin/:$PATH
export PATH
# Start from one level above the build directory
if [ -f version ]; then
@ -49,7 +49,7 @@ perl -p -i -e 's/(m4_define\(\[LIBARCHIVE_VERSION_S\]),.*\)/$1,['"$VS"'])/' conf
perl -p -i -e 's/(m4_define\(\[LIBARCHIVE_VERSION_N\]),.*\)/$1,['"$VN"'])/' configure.ac
# Remove developer CFLAGS if a release build is being made
if [ -n "${MAKE_LIBARCHIVE_RELEASE}" ]; then
if [ -n "${MAKE_LIBARCHIVE_RELEASE:-}" ]; then
perl -p -i -e "s/^(DEV_CFLAGS.*)/# \$1/" Makefile.am
perl -p -i -e 's/CMAKE_BUILD_TYPE "[A-Za-z]*"/CMAKE_BUILD_TYPE "Release"/' CMakeLists.txt
fi

View File

@ -1,4 +1,5 @@
#!/bin/sh +v
set -eu
# Start from the build directory, where the version file is located
if [ -f build/version ]; then

View File

@ -12,14 +12,18 @@
# MAKE_ARGS= # make arguments
# DEBUG= # set -g -fsanitize=address flags
set -eu
ACTIONS=
if [ -n "${BUILD_SYSTEM}" ]; then
if [ -n "${BUILD_SYSTEM:-}" ]; then
BS="${BUILD_SYSTEM}"
fi
BS="${BS:-autotools}"
MAKE="${MAKE:-make}"
CMAKE="${CMAKE:-cmake}"
CMAKE_ARGS="${CMAKE_ARGS:-}"
CONFIGURE_ARGS="${CONFIGURE_ARGS:-}"
CURDIR=`pwd`
SRCDIR="${SRCDIR:-`pwd`}"
RET=0
@ -74,7 +78,7 @@ while getopts a:b:c:d:s: opt; do
;;
esac
done
case "${CRYPTO}" in
case "${CRYPTO:-}" in
mbedtls)
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_OPENSSL=OFF -DENABLE_MBEDTLS=ON"
CONFIGURE_ARGS="${CONFIGURE_ARGS} --without-openssl --with-mbedtls"
@ -84,15 +88,21 @@ case "${CRYPTO}" in
CONFIGURE_ARGS="${CONFIGURE_ARGS} --without-openssl --with-nettle"
;;
esac
if [ -z "${MAKE_ARGS}" ]; then
if [ -z "${MAKE_ARGS:-}" ]; then
if [ "${BS}" = "autotools" ]; then
MAKE_ARGS="V=1"
elif [ "${BS}" = "cmake" ]; then
MAKE_ARGS="VERBOSE=1"
fi
fi
if [ -n "${DEBUG}" ]; then
if [ -n "${CFLAGS}" ]; then
if [ -d /opt/homebrew/include ]; then
export CFLAGS="${CFLAGS:-} -I/opt/homebrew/include"
fi
if [ -d /opt/homebrew/lib ]; then
export LDFLAGS="${LDFLAGS:-} -L/opt/homebrew/lib"
fi
if [ -n "${DEBUG:-}" ]; then
if [ -n "${CFLAGS:-}" ]; then
export CFLAGS="${CFLAGS} -g -fsanitize=address"
else
export CFLAGS="-g -fsanitize=address"
@ -104,7 +114,7 @@ fi
if [ -z "${BS}" ]; then
inputerror "Missing build system (-b) parameter"
fi
if [ -z "${BUILDDIR}" ]; then
if [ -z "${BUILDDIR:-}" ]; then
BUILDDIR="${CURDIR}/build_ci/${BS}"
fi
mkdir -p "${BUILDDIR}"
@ -141,18 +151,19 @@ for action in ${ACTIONS}; do
;;
esac
RET="$?"
find ${TMPDIR:-/tmp} -path '*_test.*' -name '*.log' -print -exec cat {} \;
find ${TMPDIR:-/tmp} -path '*_test.*' -name '*.log' -print -exec cat {} \; 2>/dev/null || /bin/true
;;
install)
${MAKE} ${MAKE_ARGS} install DESTDIR="${BUILDDIR}/destdir"
RET="$?"
cd "${BUILDDIR}/destdir" && ls -lR .
./usr/local/bin/bsdtar --version
;;
distcheck)
${MAKE} ${MAKE_ARGS} distcheck || (
RET="$?"
find . -name 'test-suite.log' -print -exec cat {} \;
find ${TMPDIR:-/tmp} -path '*_test.*' -name '*.log' -print -exec cat {} \;
find ${TMPDIR:-/tmp} -path '*_test.*' -name '*.log' -print -exec cat {} \; 2>/dev/null || /bin/true
exit "${RET}"
)
RET="$?"

View File

@ -1,4 +1,4 @@
FROM cirrusci/windowsservercore:2019
RUN choco install -y --no-progress cygwin
RUN C:\tools\cygwin\cygwinsetup.exe -q -P make,autoconf,automake,cmake,gcc-core,binutils,libtool,pkg-config,bison,sharutils,zlib-devel,libbz2-devel,liblzma-devel,liblz4-devel,libiconv-devel,libxml2-devel,libzstd-devel,libssl-devel
RUN C:\tools\cygwin\cygwinsetup.exe -q -P make,autoconf,automake,cmake,gcc-core,binutils,libtool,pkg-config,bison,zlib-devel,libbz2-devel,liblzma-devel,liblz4-devel,libiconv-devel,libxml2-devel,libzstd-devel,libssl-devel

View File

@ -1,3 +1,3 @@
FROM fedora:31
RUN dnf -y install make cmake gcc gcc-c++ kernel-devel automake libtool bison sharutils pkgconf libacl-devel libasan librichacl-devel bzip2-devel zlib-devel xz-devel lz4-devel libzstd-devel openssl-devel nettle-devel mbedtls-devel
RUN dnf -y install make cmake gcc gcc-c++ kernel-devel automake libtool bison pkgconf libacl-devel libasan librichacl-devel bzip2-devel zlib-devel xz-devel lz4-devel libzstd-devel openssl-devel nettle-devel mbedtls-devel

View File

@ -1,3 +1,3 @@
FROM fedora:31
RUN dnf -y install make cmake gcc gcc-c++ kernel-devel automake libtool bison sharutils pkgconf libacl-devel libasan librichacl-devel bzip2-devel zlib-devel xz-devel lz4-devel libzstd-devel openssl-devel groff ghostscript xz zip
RUN dnf -y install make cmake gcc gcc-c++ kernel-devel automake libtool bison pkgconf libacl-devel libasan librichacl-devel bzip2-devel zlib-devel xz-devel lz4-devel libzstd-devel openssl-devel groff ghostscript xz zip

View File

@ -9,4 +9,4 @@ RUN tar -x -f zlib-1.2.11.tar.gz
RUN cd zlib-1.2.11 && cmake -G "Visual Studio 15 2017" . && cmake --build . --target ALL_BUILD --config Release && cmake --build . --target INSTALL --config Release
RUN del /f /q /s zlib-1.2.11 zlib-1.2.11.tar.gz
RUN choco install -y --no-progress cygwin
RUN C:\tools\cygwin\cygwinsetup.exe -q -P make,autoconf,automake,cmake,gcc-core,binutils,libtool,pkg-config,bison,sharutils,zlib-devel,libbz2-devel,liblzma-devel,liblz4-devel,libiconv-devel,libxml2-devel,libzstd-devel,libssl-devel
RUN C:\tools\cygwin\cygwinsetup.exe -q -P make,autoconf,automake,cmake,gcc-core,binutils,libtool,pkg-config,bison,zlib-devel,libbz2-devel,liblzma-devel,liblz4-devel,libiconv-devel,libxml2-devel,libzstd-devel,libssl-devel

View File

@ -13,7 +13,7 @@ IF "%1%"=="prepare" (
IF "%BE%"=="cygwin-gcc" (
@ECHO ON
choco install -y --no-progress cygwin || EXIT /b 1
C:\tools\cygwin\cygwinsetup.exe -q -P make,autoconf,automake,cmake,gcc-core,binutils,libtool,pkg-config,bison,sharutils,zlib-devel,libbz2-devel,liblzma-devel,liblz4-devel,libiconv-devel,libxml2-devel,libzstd-devel,libssl-devel || EXIT /b 1
C:\tools\cygwin\cygwinsetup.exe -q -P make,autoconf,automake,cmake,gcc-core,binutils,libtool,pkg-config,bison,zlib-devel,libbz2-devel,liblzma-devel,liblz4-devel,libiconv-devel,libxml2-devel,libzstd-devel,libssl-devel || EXIT /b 1
@EXIT /b 0
) ELSE IF "%BE%"=="mingw-gcc" (
@ECHO ON

View File

@ -1,4 +1,12 @@
#!/bin/sh
set -eu
if [ $# != 1 ]
then
echo "Usage: $0 prepare | test"
exit 1
fi
UNAME=`uname`
if [ "$1" = "prepare" ]
then
@ -15,7 +23,7 @@ then
tunefs -N enable /dev/$MD
mount /dev/$MD /tmp_acl_nfsv4
chmod 1777 /tmp_acl_nfsv4
pkg install -y autoconf automake cmake libiconv libtool pkgconf expat libxml2 liblz4 zstd
pkg install -y autoconf automake cmake libiconv libtool pkgconf expat libxml2 liblz4 zstd gmake
elif [ "${UNAME}" = "Darwin" ]
then
set -x -e
@ -29,10 +37,10 @@ then
if [ -f "/etc/debian_version" ]
then
apt-get -y update
apt-get -y install build-essential locales automake libtool bison sharutils pkgconf libacl1-dev libbz2-dev zlib1g-dev liblzma-dev liblz4-dev libzstd-dev libssl-dev lrzip cmake
apt-get -y install build-essential locales automake libtool bison pkgconf libacl1-dev libbz2-dev zlib1g-dev liblzma-dev liblz4-dev libzstd-dev libssl-dev lrzip cmake
elif [ -f "/etc/fedora-release" ]
then
dnf -y install make cmake gcc gcc-c++ kernel-devel automake libtool bison sharutils pkgconf libacl-devel librichacl-devel bzip2-devel zlib-devel xz-devel lz4-devel libzstd-devel openssl-devel
dnf -y install make cmake gcc gcc-c++ kernel-devel automake libtool bison pkgconf libacl-devel librichacl-devel bzip2-devel zlib-devel xz-devel lz4-devel libzstd-devel openssl-devel
fi
fi
elif [ "$1" = "test" ]
@ -53,6 +61,6 @@ then
TMPDIR=/tmp_acl_nfsv4 ${BIN_SUBDIR}/libarchive_test -r "${CURDIR}/libarchive/test" -v test_acl_platform_nfs4
fi
else
echo "Usage $0 prepare | test_nfsv4_acls"
echo "Usage: $0 prepare | test"
exit 1
fi

View File

@ -1,7 +1,7 @@
@ECHO OFF
SET ZLIB_VERSION=1.3
SET BZIP2_VERSION=1ea1ac188ad4b9cb662e3f8314673c63df95a589
SET XZ_VERSION=5.4.4
SET XZ_VERSION=5.6.3
IF NOT "%BE%"=="mingw-gcc" (
IF NOT "%BE%"=="msvc" (
ECHO Environment variable BE must be mingw-gcc or msvc
@ -64,7 +64,7 @@ IF "%1"=="deplibs" (
IF "%BE%"=="mingw-gcc" (
SET PATH=%MINGWPATH%
cmake -G "MinGW Makefiles" -D CMAKE_BUILD_TYPE="Release" . || EXIT /b 1
mingw32-make || EXIT /b 1
mingw32-make -j %NUMBER_OF_PROCESSORS% || EXIT /b 1
mingw32-make test || EXIT /b 1
mingw32-make install || EXIT /b 1
) ELSE IF "%BE%"=="msvc" (
@ -78,7 +78,7 @@ IF "%1"=="deplibs" (
IF "%BE%"=="mingw-gcc" (
SET PATH=%MINGWPATH%
cmake -G "MinGW Makefiles" -D CMAKE_BUILD_TYPE="Release" -D ENABLE_LIB_ONLY=ON -D ENABLE_SHARED_LIB=OFF -D ENABLE_STATIC_LIB=ON . || EXIT /b 1
mingw32-make || EXIT /b 1
mingw32-make -j %NUMBER_OF_PROCESSORS% || EXIT /b 1
REM mingw32-make test || EXIT /b 1
mingw32-make install || EXIT /b 1
) ELSE IF "%BE%"=="msvc" (
@ -92,7 +92,7 @@ IF "%1"=="deplibs" (
IF "%BE%"=="mingw-gcc" (
SET PATH=%MINGWPATH%
cmake -G "MinGW Makefiles" -D CMAKE_BUILD_TYPE="Release" . || EXIT /b 1
mingw32-make || EXIT /b 1
mingw32-make -j %NUMBER_OF_PROCESSORS% || EXIT /b 1
mingw32-make install || EXIT /b 1
) ELSE IF "%BE%"=="msvc" (
cmake -G "Visual Studio 17 2022" -D CMAKE_BUILD_TYPE="Release" . || EXIT /b 1
@ -104,7 +104,7 @@ IF "%1"=="deplibs" (
IF "%BE%"=="mingw-gcc" (
SET PATH=%MINGWPATH%
cmake -G "MinGW Makefiles" -D CMAKE_BUILD_TYPE="Release" . || EXIT /b 1
mingw32-make || EXIT /b 1
mingw32-make -j %NUMBER_OF_PROCESSORS% || EXIT /b 1
mingw32-make install || EXIT /b 1
) ELSE IF "%BE%"=="msvc" (
cmake -G "Visual Studio 17 2022" -D CMAKE_BUILD_TYPE="Release" . || EXIT /b 1
@ -120,13 +120,13 @@ IF "%1"=="deplibs" (
) ELSE IF "%BE%"=="msvc" (
MKDIR build_ci\cmake
CD build_ci\cmake
cmake -G "Visual Studio 17 2022" -D CMAKE_BUILD_TYPE="Release" -D ZLIB_LIBRARY="C:/Program Files (x86)/zlib/lib/zlibstatic.lib" -D ZLIB_INCLUDE_DIR="C:/Program Files (x86)/zlib/include" -D BZIP2_LIBRARIES="C:/Program Files (x86)/bzip2/lib/bz2_static.lib" -D BZIP2_INCLUDE_DIR="C:/Program Files (x86)/bzip2/include" -D LIBLZMA_LIBRARY="C:/Program Files (x86)/xz/lib/liblzma.lib" -D LIBLZMA_INCLUDE_DIR="C:/Program Files (x86)/xz/include" -D ZSTD_LIBRARY="C:/Program Files (x86)/zstd/lib/zstd_static.lib" -D ZSTD_INCLUDE_DIR="C:/Program Files (x86)/zstd/include" ..\.. || EXIT /b 1
cmake -G "Visual Studio 17 2022" -D CMAKE_BUILD_TYPE="Release" -D ZLIB_LIBRARY="C:/Program Files (x86)/zlib/lib/zlibstatic.lib" -D ZLIB_INCLUDE_DIR="C:/Program Files (x86)/zlib/include" -D BZIP2_LIBRARIES="C:/Program Files (x86)/bzip2/lib/bz2_static.lib" -D BZIP2_INCLUDE_DIR="C:/Program Files (x86)/bzip2/include" -D LIBLZMA_LIBRARY="C:/Program Files (x86)/xz/lib/lzma.lib" -D LIBLZMA_INCLUDE_DIR="C:/Program Files (x86)/xz/include" -D ZSTD_LIBRARY="C:/Program Files (x86)/zstd/lib/zstd_static.lib" -D ZSTD_INCLUDE_DIR="C:/Program Files (x86)/zstd/include" ..\.. || EXIT /b 1
)
) ELSE IF "%1%"=="build" (
IF "%BE%"=="mingw-gcc" (
SET PATH=%MINGWPATH%
CD build_ci\cmake
mingw32-make VERBOSE=1 || EXIT /b 1
mingw32-make -j %NUMBER_OF_PROCESSORS% VERBOSE=1 || EXIT /b 1
) ELSE IF "%BE%"=="msvc" (
CD build_ci\cmake
cmake --build . --target ALL_BUILD --config Release || EXIT /b 1
@ -138,10 +138,8 @@ IF "%1"=="deplibs" (
SET SKIP_TEST_SPARSE=1
mingw32-make test VERBOSE=1 || EXIT /b 1
) ELSE IF "%BE%"=="msvc" (
ECHO "Skipping tests on this platform"
EXIT /b 0
REM CD build_ci\cmake
REM cmake --build . --target RUN_TESTS --config Release || EXIT /b 1
CD build_ci\cmake
cmake --build . --target RUN_TESTS --config Release || EXIT /b 1
)
) ELSE IF "%1%"=="install" (
IF "%BE%"=="mingw-gcc" (
@ -152,6 +150,7 @@ IF "%1"=="deplibs" (
CD build_ci\cmake
cmake --build . --target INSTALL --config Release || EXIT /b 1
)
"C:\Program Files (x86)\libarchive\bin\bsdtar.exe" --version
) ELSE IF "%1"=="artifact" (
C:\windows\system32\tar.exe -c -C "C:\Program Files (x86)" --format=zip -f libarchive.zip libarchive
) ELSE (

View File

@ -0,0 +1,22 @@
#!/bin/sh
set -eux
# Uncommenting these adds a full minute to the CI time
#brew update > /dev/null
#brew upgrade > /dev/null
# Workaround for cmake in local/pinned tap issue
brew uninstall cmake
# This does an upgrade if the package is already installed
brew install \
autoconf \
automake \
libtool \
pkg-config \
cmake \
xz \
lz4 \
zstd \
libxml2 \
openssl

View File

@ -1,21 +0,0 @@
#!/bin/sh
if [ "$1" = "prepare" ]
then
set -x -e
#Uncommenting these adds a full minute to the CI time
#brew update > /dev/null
#brew upgrade > /dev/null
# This does an upgrade if the package is already installed
brew install \
autoconf \
automake \
libtool \
pkg-config \
cmake \
xz \
lz4 \
zstd \
libxml2 \
openssl
fi

View File

@ -1,33 +0,0 @@
#!/bin/sh
set -e
UNAME=`uname`
CURDIR=`pwd`
SRCDIR="${SRCDIR:-`pwd`}"
if [ -z "${BUILDDIR}" ]; then
BUILDDIR="${CURDIR}/build_ci/${BS}"
fi
mkdir -p "${BUILDDIR}"
cd "${BUILDDIR}"
case "$UNAME" in
MSYS*)
if [ "${BS}" = "msbuild" ]; then
set -x
cmake -G "Visual Studio 15 2017" -D CMAKE_BUILD_TYPE="Release" "${SRCDIR}"
cmake --build . --target ALL_BUILD
# Until fixed, we don't run tests on Windows (lots of fails + timeout)
#export SKIP_TEST_FUZZ=1
#cmake --build . --target RUN_TESTS
set +x
elif [ "${BS}" = "mingw" ]; then
set -x
cmake -G "MSYS Makefiles" -D CMAKE_C_COMPILER="${CC}" -D CMAKE_MAKE_PROGRAM="mingw32-make" -D CMAKE_BUILD_TYPE="Release" "${SRCDIR}"
mingw32-make
#export SKIP_TEST_FUZZ=1
#mingw32-make test
set +x
else
echo "Unknown or unspecified build type: ${BS}"
exit 1
fi
;;
esac

View File

@ -1,4 +1,5 @@
#!/bin/sh
set -eu
#
# Attempt to remove as many generated files as we can.

View File

@ -29,5 +29,5 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc.in
# And install it, of course ;).
IF(ENABLE_INSTALL)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/build/pkgconfig/libarchive.pc
DESTINATION "lib/pkgconfig")
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
ENDIF()

View File

@ -19,13 +19,13 @@
# xdg-open coverage/index.html
#################################################################
# Find programs we need
# Find programs we need
FIND_PROGRAM(LCOV_EXECUTABLE lcov DOC "Full path to lcov executable")
FIND_PROGRAM(GENHTML_EXECUTABLE genhtml DOC "Full path to genhtml executable")
MARK_AS_ADVANCED(LCOV_EXECUTABLE GENHTML_EXECUTABLE)
# Check, compiler, build types and programs are available
IF(NOT CMAKE_COMPILER_IS_GNUCC)
IF(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU")
MESSAGE(FATAL_ERROR "Coverage can only be built on GCC")
ELSEIF(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
MESSAGE(FATAL_ERROR "Coverage can only be built in Debug mode")
@ -33,7 +33,7 @@ ELSEIF(NOT LCOV_EXECUTABLE)
MESSAGE(FATAL_ERROR "lcov executable not found")
ELSEIF(NOT GENHTML_EXECUTABLE)
MESSAGE(FATAL_ERROR "genhtml executable not found")
ENDIF(NOT CMAKE_COMPILER_IS_GNUCC)
ENDIF()
# Enable testing if not already done
SET(ENABLE_TEST ON)

View File

@ -405,6 +405,12 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the `chroot' function. */
#cmakedefine HAVE_CHROOT 1
/* Define to 1 if you have the `closefrom' function. */
#cmakedefine HAVE_CLOSEFROM 1
/* Define to 1 if you have the `close_range' function. */
#cmakedefine HAVE_CLOSE_RANGE 1
/* Define to 1 if you have the <copyfile.h> header file. */
#cmakedefine HAVE_COPYFILE_H 1
@ -729,15 +735,15 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the `gcc' library (-lgcc). */
#cmakedefine HAVE_LIBGCC 1
/* Define to 1 if you have the `iconv' library (-liconv). */
#cmakedefine HAVE_LIBICONV 1
/* Define to 1 if you have the `lz4' library (-llz4). */
#cmakedefine HAVE_LIBLZ4 1
/* Define to 1 if you have the `lzma' library (-llzma). */
#cmakedefine HAVE_LIBLZMA 1
/* Define to 1 if you have the `lzmadec' library (-llzmadec). */
#cmakedefine HAVE_LIBLZMADEC 1
/* Define to 1 if you have the `lzo2' library (-llzo2). */
#cmakedefine HAVE_LIBLZO2 1
@ -768,6 +774,9 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the <libxml/xmlwriter.h> header file. */
#cmakedefine HAVE_LIBXML_XMLWRITER_H 1
/* Define to 1 if you have the <libxml/xmlversion.h> header file. */
#cmakedefine HAVE_LIBXML_XMLVERSION_H 1
/* Define to 1 if you have the `z' library (-lz). */
#cmakedefine HAVE_LIBZ 1
@ -777,6 +786,9 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the ZSTD_compressStream function. */
#cmakedefine HAVE_ZSTD_compressStream 1
/* Define to 1 if you have the ZSTD_minCLevel function. */
#cmakedefine HAVE_ZSTD_minCLevel 1
/* Define to 1 if you have the <limits.h> header file. */
#cmakedefine HAVE_LIMITS_H 1
@ -847,9 +859,6 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the <lz4.h> header file. */
#cmakedefine HAVE_LZ4_H 1
/* Define to 1 if you have the <lzmadec.h> header file. */
#cmakedefine HAVE_LZMADEC_H 1
/* Define to 1 if you have the <lzma.h> header file. */
#cmakedefine HAVE_LZMA_H 1
@ -871,6 +880,9 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the <mbedtls/pkcs5.h> header file. */
#cmakedefine HAVE_MBEDTLS_PKCS5_H 1
/* Define to 1 if you have the <mbedtls/pkcs5.h> header file. */
#cmakedefine HAVE_MBEDTLS_VERSION_H 1
/* Define to 1 if you have the `mbrtowc' function. */
#cmakedefine HAVE_MBRTOWC 1
@ -916,6 +928,9 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the <nettle/sha.h> header file. */
#cmakedefine HAVE_NETTLE_SHA_H 1
/* Define to 1 if you have the <nettle/version.h> header file. */
#cmakedefine HAVE_NETTLE_VERSION_H 1
/* Define to 1 if you have the `nl_langinfo' function. */
#cmakedefine HAVE_NL_LANGINFO 1
@ -925,6 +940,9 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the <openssl/evp.h> header file. */
#cmakedefine HAVE_OPENSSL_EVP_H 1
/* Define to 1 if you have the <openssl/opensslv.h> header file. */
#cmakedefine HAVE_OPENSSL_OPENSSLV_H 1
/* Define to 1 if you have the <paths.h> header file. */
#cmakedefine HAVE_PATHS_H 1
@ -958,9 +976,6 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the <pwd.h> header file. */
#cmakedefine HAVE_PWD_H 1
/* Define to 1 if you have the `readdir_r' function. */
#cmakedefine HAVE_READDIR_R 1
/* Define to 1 if you have the `readlink' function. */
#cmakedefine HAVE_READLINK 1
@ -1147,7 +1162,6 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the <sys/stat.h> header file. */
#cmakedefine HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/sysmacros.h> header file. */
#cmakedefine HAVE_SYS_SYSMACROS_H 1
@ -1172,6 +1186,12 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the <sys/xattr.h> header file. */
#cmakedefine HAVE_SYS_XATTR_H 1
/* Define to 1 if you have the `tcgetattr' function. */
#cmakedefine HAVE_TCGETATTR 1
/* Define to 1 if you have the `tcsetattr' function. */
#cmakedefine HAVE_TCSETATTR 1
/* Define to 1 if you have the `timegm' function. */
#cmakedefine HAVE_TIMEGM 1
@ -1265,6 +1285,9 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have a working FS_IOC_GETFLAGS */
#cmakedefine HAVE_WORKING_FS_IOC_GETFLAGS 1
/* Define to 1 if you have the Windows `xmllite' library (-lxmllite). */
#cmakedefine HAVE_XMLLITE_H 1
/* Define to 1 if you have the <zlib.h> header file. */
#cmakedefine HAVE_ZLIB_H 1
@ -1322,6 +1345,15 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#cmakedefine TIME_WITH_SYS_TIME 1
/* Version number of package */
#cmakedefine LIBATTR_PKGCONFIG_VERSION "@LIBATTR_PKGCONFIG_VERSION@"
/* Version number of package */
#cmakedefine LIBACL_PKGCONFIG_VERSION "@LIBACL_PKGCONFIG_VERSION@"
/* Version number of package */
#cmakedefine LIBRICHACL_PKGCONFIG_VERSION "@LIBRICHACL_PKGCONFIG_VERSION@"
/*
* Some platform requires a macro to use extension functions.
*/

View File

@ -1,4 +1,5 @@
#!/bin/sh
set -eu
#
# This script exists primarily to document some of the
@ -8,7 +9,6 @@
#
PATH=/usr/local/gnu-autotools/bin/:$PATH
export PATH
# Start from one level above the build directory
if [ -f version ]; then
@ -24,7 +24,7 @@ fi
# Makefile. Effectively disable it.
export MAKEOBJDIRPREFIX=/junk
set -ex
set -x
#
# Scrub the local tree before running the build tests below.

View File

@ -1,8 +1,10 @@
#!/bin/sh
set -eu
ID=$(docker build -q -f build/release/Dockerfile .)
if [ -z "$ID" ]; then
echo "Failed to build docker image"
exit 1
else
docker run $ID sh -c "tar -c -f - libarchive-*" | tar -x -f -
docker run "$ID" sh -c "tar -c -f - libarchive-*" | tar -x -f -
fi

View File

@ -1,4 +1,12 @@
#!/bin/sh
set -eu
if [ $# != 1 ]
then
echo "Usage: $0 path/to/UnicodeData.txt"
exit 1
fi
#
# This needs http://unicode.org/Public/6.0.0/ucd/UnicodeData.txt
#

View File

@ -1 +1 @@
3007005
3009000

View File

@ -1,3 +1,6 @@
#
# SPDX-License-Identifier: BSD-2-Clause
#
############################################
#
# How to build bsdcat
@ -10,8 +13,8 @@ IF(ENABLE_CAT)
bsdcat.h
bsdcat_platform.h
cmdline.c
../libarchive_fe/err.c
../libarchive_fe/err.h
../libarchive_fe/lafe_err.c
../libarchive_fe/lafe_err.h
../libarchive_fe/lafe_platform.h
)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libarchive_fe)
@ -30,8 +33,10 @@ IF(ENABLE_CAT)
ENDIF(ENABLE_CAT_SHARED)
# Installation rules
INSTALL(TARGETS bsdcat RUNTIME DESTINATION bin)
INSTALL_MAN(${bsdcat_MANS})
IF(ENABLE_INSTALL)
INSTALL(TARGETS bsdcat RUNTIME DESTINATION bin)
INSTALL_MAN(${bsdcat_MANS})
ENDIF(ENABLE_INSTALL)
ENDIF(ENABLE_CAT)
add_subdirectory(test)

View File

@ -1,27 +1,9 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2011-2014, Mike Kazantsev
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd March 1, 2014
.Dt BSDCAT 1
.Os

View File

@ -1,30 +1,15 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011-2014, Mike Kazantsev
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "bsdcat_platform.h"
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
@ -40,7 +25,7 @@
#include <archive_entry.h>
#include "bsdcat.h"
#include "err.h"
#include "lafe_err.h"
#define BYTES_PER_BLOCK (20*512)
@ -123,6 +108,16 @@ main(int argc, char **argv)
bsdcat = &bsdcat_storage;
memset(bsdcat, 0, sizeof(*bsdcat));
#if defined(HAVE_SIGACTION) && defined(SIGCHLD)
{ /* Do not ignore SIGCHLD. */
struct sigaction sa;
sa.sa_handler = SIG_DFL;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sigaction(SIGCHLD, &sa, NULL);
}
#endif
lafe_setprogname(*argv, "bsdcat");
bsdcat->argv = argv;

View File

@ -1,26 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014, Mike Kazantsev
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef BSDCAT_H_INCLUDED

View File

@ -1,26 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003-2007 Tim Kientzle
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
@ -58,7 +40,7 @@
#define __LA_NORETURN __attribute__((__noreturn__))
#elif defined(_MSC_VER)
#define __LA_NORETURN __declspec(noreturn)
#else
#else
#define __LA_NORETURN
#endif

View File

@ -1,26 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003-2008 Tim Kientzle
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
@ -40,7 +22,7 @@
#endif
#include "bsdcat.h"
#include "err.h"
#include "lafe_err.h"
/*
* Short options for bsdcat. Please keep this sorted.

View File

@ -1,3 +1,6 @@
#
# SPDX-License-Identifier: BSD-2-Clause
#
############################################
#
# How to build bsdtar_test
@ -61,7 +64,9 @@ IF(ENABLE_CAT AND ENABLE_TEST)
COMMAND bsdcat_test -vv
-p $<TARGET_FILE:bsdcat>
-r ${CMAKE_CURRENT_SOURCE_DIR}
-s
${_testname})
SET_TESTS_PROPERTIES(bsdcat_${_testname} PROPERTIES SKIP_RETURN_CODE 2)
ENDMACRO (DEFINE_TEST _testname)
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)

View File

@ -1,26 +1,8 @@
/*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003-2006 Tim Kientzle
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Every test program should #include "test.h" as the first thing. */

View File

@ -1,26 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003-2007 Tim Kientzle
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -1,26 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Sebastian Freundt
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -1,26 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Sebastian Freundt
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -1,26 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Sebastian Freundt
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -1,26 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2017 Sean Purcell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -1,26 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Mike Kazantsev
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -1,26 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Mike Kazantsev
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -1,26 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Mike Kazantsev
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -1,27 +1,9 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Mike Kazantsev
* Copyright (c) 2012 Michihiro NAKAJIMA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -1,27 +1,9 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Mike Kazantsev
* Copyright (c) 2012 Michihiro NAKAJIMA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -1,27 +1,9 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Mike Kazantsev
* Copyright (c) 2012, 2014 Michihiro NAKAJIMA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -1,26 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Mike Kazantsev
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -1,26 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Mike Kazantsev
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -1,27 +1,9 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Mike Kazantsev
* Copyright (c) 2012 Michihiro NAKAJIMA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -1,26 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2017 Sean Purcell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -1,26 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003-2007 Tim Kientzle
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -1,26 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2017 Sean Purcell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -1,26 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003-2017 Tim Kientzle
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"

View File

@ -4,8 +4,8 @@ dnl First, define all of the version numbers up front.
dnl In particular, this allows the version macro to be used in AC_INIT
dnl These first two version numbers are updated automatically on each release.
m4_define([LIBARCHIVE_VERSION_S],[3.7.5])
m4_define([LIBARCHIVE_VERSION_N],[3007005])
m4_define([LIBARCHIVE_VERSION_S],[3.9.0dev])
m4_define([LIBARCHIVE_VERSION_N],[3009000])
dnl bsdtar and bsdcpio versioning tracks libarchive
m4_define([BSDTAR_VERSION_S],LIBARCHIVE_VERSION_S())
@ -38,7 +38,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
ARCHIVE_MINOR=$(( (LIBARCHIVE_VERSION_N() / 1000) % 1000 ))
# Libarchive 2.7 == libtool interface 9 = 2 + 7
# Libarchive 2.8 == libtool interface 10 = 2 + 8
# Libarchive 2.9 == libtool interface 11 = 2 + 8
# Libarchive 2.9 == libtool interface 11 = 2 + 9
# Libarchive 3.0 == libtool interface 12
# Libarchive 3.1 == libtool interface 13
ARCHIVE_INTERFACE=`echo $((13 + ${ARCHIVE_MINOR}))`
@ -108,6 +108,11 @@ case "$host_os" in
esac
AC_SUBST(PLATFORMCPPFLAGS)
dnl Linking on Haiku needs libbsd because of readpassphrase
case "$host_os" in
haiku*) LIBS="-lbsd $LIBS" ;;
esac
# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
@ -253,7 +258,8 @@ AM_CONDITIONAL([STATIC_BSDCPIO], [ test "$static_bsdcpio" = yes ])
case $host in
*mingw* | *cygwin* | *msys* )
AC_PREPROC_IFELSE([AC_LANG_PROGRAM(
[[#ifdef _WIN32_WINNT
[[#include <windows.h>
#ifdef _WIN32_WINNT
# error _WIN32_WINNT already defined
#endif
]],[[;]])
@ -262,7 +268,8 @@ case $host in
AC_DEFINE([NTDDI_VERSION], 0x05020000, [Define to '0x05020000' for Windows Server 2003 APIs.])
])
AC_PREPROC_IFELSE([AC_LANG_PROGRAM(
[[#ifdef WINVER
[[#include <windows.h>
#ifdef WINVER
# error WINVER already defined
#endif
]],[[;]])
@ -367,9 +374,10 @@ AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/richacl.h])
AC_CHECK_HEADERS([sys/select.h sys/statfs.h sys/statvfs.h sys/sysmacros.h])
AC_CHECK_HEADERS([sys/time.h sys/utime.h sys/utsname.h sys/vfs.h sys/xattr.h])
AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h wctype.h])
AC_CHECK_TYPE([suseconds_t])
AC_CHECK_HEADERS([windows.h])
# check windows.h first; the other headers require it.
AC_CHECK_HEADERS([wincrypt.h winioctl.h],[],[],
AC_CHECK_HEADERS([winioctl.h],[],[],
[[#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
@ -393,6 +401,7 @@ if test "x$with_zlib" != "xno"; then
int main(int argc, char **argv) { inflate(NULL, 0); return 0; }
]])],
[AC_DEFINE([HAVE_ZLIB_H], [1], [Define to 1 if you have zlib >= 1.2.1])
AC_DEFINE([HAVE_LIBZ], [1], [Define to 1 if you have zlib >= 1.2.1])
AC_MSG_RESULT([found a suitable version of zlib (>= 1.2.1)])
],
[AC_MSG_RESULT([could not find a suitable version of zlib (>= 1.2.1)])
@ -429,12 +438,18 @@ if test "x$with_bz2lib" != "xno"; then
esac
fi
PKG_PROG_PKG_CONFIG
AC_ARG_WITH([libb2],
AS_HELP_STRING([--without-libb2], [Don't build support for BLAKE2 through libb2]))
if test "x$with_libb2" != "xno"; then
AC_CHECK_HEADERS([blake2.h])
AC_CHECK_LIB(b2,blake2sp_init)
BLAKE2_PC_VER=`$PKG_CONFIG --modversion libb2`
if test "x$BLAKE2_PC_VER" != "x"; then
AC_DEFINE_UNQUOTED([LIBB2_PKGCONFIG_VERSION], ["$BLAKE2_PC_VER"], [Libb2 version coming from pkg-config.])
fi
fi
AM_CONDITIONAL([INC_BLAKE2], [test "x$ac_cv_lib_b2_blake2sp_init" != "xyes"])
@ -447,13 +462,17 @@ if test "x$with_iconv" != "xno"; then
AC_CHECK_HEADERS([iconv.h],[],[],[#include <stdlib.h>])
if test "x$am_cv_func_iconv" = "xyes"; then
AC_CHECK_HEADERS([localcharset.h])
am_save_LIBS="$LIBS"
LIBS="${LIBS} ${LIBICONV}"
if test -n "$LIBICONV"; then
LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }iconv"
AC_DEFINE([HAVE_LIBICONV], [1], [Define to 1 if you have the `iconv' library (-liconv).])
# Most platforms do not provide iconv.pc, but MSYS2 MinGW does.
# We add it to our Requires.private only if it exists.
PKG_CHECK_MODULES(ICONV_PC, [iconv], [
LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }iconv"
], [true])
fi
AC_CHECK_FUNCS([locale_charset])
LIBS="${am_save_LIBS}"
if test "x$ac_cv_func_locale_charset" != "xyes"; then
# If locale_charset() is not in libiconv, we have to find libcharset.
AC_CHECK_LIB(charset,locale_charset)
@ -477,14 +496,24 @@ if test "x$with_zstd" != "xno"; then
AC_CHECK_LIB(zstd,ZSTD_decompressStream)
AC_CHECK_LIB(zstd,ZSTD_compressStream,
AC_DEFINE([HAVE_ZSTD_compressStream], [1], [Define to 1 if you have the `zstd' library (-lzstd) with compression support.]))
AC_CHECK_LIB(zstd,ZSTD_minCLevel,
AC_DEFINE([HAVE_ZSTD_minCLevel], [1], [Define to 1 if you have a `zstd' library version with ZSTD_minCLevel().]))
fi
AC_ARG_WITH([lzma],
AS_HELP_STRING([--without-lzma], [Don't build support for xz through lzma]))
if test "x$with_lzma" != "xno"; then
PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES(LZMA_PC, [liblzma], [
CPPFLAGS="${CPPFLAGS} ${LZMA_PC_CFLAGS}"
LIBS="${LIBS} ${LZMA_PC_LIBS}"
AC_DEFINE(HAVE_LIBLZMA, [1], [Define to 1 if you have the `lzma' library.])
], [
AC_CHECK_LIB(lzma,lzma_stream_decoder)
])
AC_CHECK_HEADERS([lzma.h])
AC_CHECK_LIB(lzma,lzma_stream_decoder)
# Some pre-release (but widely distributed) versions of liblzma
# included a disabled version of lzma_stream_encoder_mt that
# fools a naive AC_CHECK_LIB or AC_CHECK_FUNC, so we need
@ -502,19 +531,6 @@ if test "x$with_lzma" != "xno"; then
if test "x$ac_cv_lzma_has_mt" != xno; then
AC_DEFINE([HAVE_LZMA_STREAM_ENCODER_MT], [1], [Define to 1 if you have the `lzma_stream_encoder_mt' function.])
fi
AC_CACHE_CHECK(
[whether we have ARM64 filter support in lzma],
ac_cv_lzma_has_arm64,
[AC_LINK_IFELSE([
AC_LANG_PROGRAM([[#include <lzma.h>]
[#ifndef LZMA_FILTER_ARM64]
[#error unsupported]
[#endif]])],
[ac_cv_lzma_has_arm64=yes], [ac_cv_lzma_has_arm64=no])])
if test "x$ac_cv_lzma_has_arm64" != xno; then
AC_DEFINE([HAVE_LZMA_FILTER_ARM64], [1], [Define to 1 if you have the `LZMA_FILTER_ARM64' macro.])
fi
fi
AC_ARG_WITH([lzo2],
@ -552,7 +568,7 @@ if test "x$with_xml2" != "xno"; then
], [
AC_CHECK_LIB(xml2,xmlInitParser)
])
AC_CHECK_HEADERS([libxml/xmlreader.h libxml/xmlwriter.h])
AC_CHECK_HEADERS([libxml/xmlreader.h libxml/xmlwriter.h libxml/xmlversion.h])
fi
if test "x$ac_cv_header_libxml_xmlreader_h" != "xyes"; then
if test "x$with_expat" != "xno"; then
@ -805,20 +821,25 @@ AC_FUNC_VPRINTF
# To avoid necessity for including windows.h or special forward declaration
# workarounds, we use 'void *' for 'struct SECURITY_ATTRIBUTES *'
AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *])
AC_CHECK_FUNCS([arc4random_buf chflags chown chroot ctime_r])
AC_CHECK_FUNCS([arc4random_buf chflags chown chroot])
AC_CHECK_FUNCS([closefrom close_range ctime_r])
AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fdopendir fnmatch fork])
AC_CHECK_FUNCS([fstat fstatat fstatfs fstatvfs ftruncate])
AC_CHECK_FUNCS([futimens futimes futimesat])
AC_CHECK_FUNCS([geteuid getline getpid getgrgid_r getgrnam_r])
AC_CHECK_FUNCS([getpwnam_r getpwuid_r getvfsbyname gmtime_r])
AC_CHECK_FUNCS([getegid geteuid getline getpid getresgid getresuid])
AC_CHECK_FUNCS([getgrgid_r getgrnam_r getpwnam_r getpwuid_r])
AC_CHECK_FUNCS([getvfsbyname gmtime_r])
AC_CHECK_FUNCS([issetugid])
AC_CHECK_FUNCS([lchflags lchmod lchown link linkat localtime_r lstat lutimes])
AC_CHECK_FUNCS([mbrtowc memmove memset])
AC_CHECK_FUNCS([mkdir mkfifo mknod mkstemp])
AC_CHECK_FUNCS([nl_langinfo openat pipe poll posix_spawnp readlink readlinkat])
AC_CHECK_FUNCS([nl_langinfo openat pipe poll posix_spawn posix_spawnp])
AC_CHECK_FUNCS([readlink readlinkat])
AC_CHECK_FUNCS([readpassphrase])
AC_CHECK_FUNCS([select setenv setlocale sigaction statfs statvfs])
AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strnlen strrchr symlink])
AC_CHECK_FUNCS([sysconf])
AC_CHECK_FUNCS([tcgetattr tcsetattr])
AC_CHECK_FUNCS([timegm tzset unlinkat unsetenv utime utimensat utimes vfork])
AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy wmemmove])
AC_CHECK_FUNCS([_fseeki64 _get_timezone])
@ -864,14 +885,6 @@ AC_CHECK_TYPES(struct statfs,,,
#include <sys/mount.h>
])
# There are several variants of readdir_r around; we only
# accept the POSIX-compliant version.
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[#include <dirent.h>]],
[[DIR *dir; struct dirent e, *r;
return(readdir_r(dir, &e, &r));]])],
[AC_DEFINE(HAVE_READDIR_R,1,[Define to 1 if you have a POSIX compatible readdir_r])]
)
# dirfd can be either a function or a macro.
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[#include <dirent.h>
@ -912,6 +925,10 @@ if test "x$enable_xattr" != "xno"; then
])
AC_CHECK_DECLS([XATTR_NOFOLLOW], [], [], [#include <sys/xattr.h>
])
ATTR_PC_VER=`$PKG_CONFIG --modversion libattr`
if test "x$ATTR_PC_VER" != "x"; then
AC_DEFINE_UNQUOTED([LIBATTR_PKGCONFIG_VERSION], ["$ATTR_PC_VER"], [Libattr version coming from pkg-config.])
fi
if test "x$ac_cv_header_sys_xattr_h" = "xyes" \
-a "x$ac_cv_have_decl_XATTR_NOFOLLOW" = "xyes"; then
# Darwin extended attributes support
@ -923,9 +940,7 @@ if test "x$enable_xattr" != "xno"; then
listxattr \
setxattr,
[ac_cv_archive_xattr_darwin=yes],
[ac_cv_archive_xattr_darwin=no],
[#include <sys/xattr.h>
])
[ac_cv_archive_xattr_darwin=no])
]
)
elif test "x$ac_cv_header_sys_extattr_h" = "xyes" \
@ -941,10 +956,7 @@ if test "x$enable_xattr" != "xno"; then
extattr_set_fd \
extattr_set_link,
[ac_cv_archive_xattr_freebsd=yes],
[ac_cv_archive_xattr_freebsd=no],
[#include <sys/types.h>
#include <sys/extattr.h>
])
[ac_cv_archive_xattr_freebsd=no])
]
)
elif test "x$ac_cv_header_sys_xattr_h" = "xyes" \
@ -960,17 +972,7 @@ if test "x$enable_xattr" != "xno"; then
llistxattr \
lsetxattr,
[ac_cv_archive_xattr_linux=yes],
[ac_cv_archive_xattr_linux=no],
[#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_SYS_XATTR_H
#include <sys/xattr.h>
#endif
#if HAVE_ATTR_XATTR_H
#include <attr/xatr.h>
#endif
])
[ac_cv_archive_xattr_linux=no])
]
)
elif test "x$ac_cv_header_sys_ea_h" = "xyes"; then
@ -985,9 +987,7 @@ if test "x$enable_xattr" != "xno"; then
llistea \
lsetea,
[ac_cv_archive_xattr_aix=yes],
[ac_cv_archive_xattr_aix=no],
[#include <sys/ea.h>
])
[ac_cv_archive_xattr_aix=no])
]
)
fi
@ -1024,7 +1024,10 @@ AC_ARG_ENABLE([acl],
if test "x$enable_acl" != "xno"; then
# Libacl
AC_CHECK_LIB([acl], [acl_get_file])
ACL_PC_VER=`$PKG_CONFIG --modversion libacl`
if test "x$ACL_PC_VER" != "x"; then
AC_DEFINE_UNQUOTED([LIBACL_PKGCONFIG_VERSION], ["$ACL_PC_VER"], [Libacl version coming from pkg-config.])
fi
AC_CHECK_TYPES([acl_t, acl_entry_t, acl_permset_t, acl_tag_t], [], [], [
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
@ -1035,7 +1038,10 @@ if test "x$enable_acl" != "xno"; then
])
AC_CHECK_LIB([richacl], [richacl_get_file])
RICHACL_PC_VER=`$PKG_CONFIG --modversion librichacl`
if test "x$RICHACL_PC_VER" != "x"; then
AC_DEFINE_UNQUOTED([LIBRICHACL_PKGCONFIG_VERSION], ["$RICHACL_PC_VER"], [Librichacl version coming from pkg-config.])
fi
AC_CHECK_TYPES([[struct richace], [struct richacl]], [], [], [
#if HAVE_SYS_RICHACL_H
#include <sys/richacl.h>
@ -1056,7 +1062,7 @@ if test "x$enable_acl" != "xno"; then
richacl_get_file \
richacl_set_fd \
richacl_set_file,
[ac_cv_archive_acl_librichacl=yes], [ac_cv_archive_acl_librichacl=no], [#include <sys/richacl.h>])])
[ac_cv_archive_acl_librichacl=yes], [ac_cv_archive_acl_librichacl=no])])
fi
if test "x$ac_cv_func_acl" = "xyes" \
@ -1098,14 +1104,7 @@ if test "x$enable_acl" != "xno"; then
acl_set_file \
acl_set_qualifier \
acl_set_tag_type,
[ac_cv_posix_acl_funcs=yes], [ac_cv_posix_acl_funcs=no],
[#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_SYS_ACL_H
#include <sys/acl.h>
#endif
])
[ac_cv_posix_acl_funcs=yes], [ac_cv_posix_acl_funcs=no])
])
AC_CHECK_FUNCS(acl_get_perm)
@ -1132,14 +1131,11 @@ if test "x$enable_acl" != "xno"; then
acl_is_trivial_np \
acl_set_entry_type_np \
acl_set_fd_np \
acl_set_link_np,,,
[#include <sys/types.h>
#include <sys/acl.h>])
acl_set_link_np)
AC_CHECK_FUNCS(mbr_uid_to_uuid \
mbr_uuid_to_id \
mbr_gid_to_uuid,,,
[#include <membership.h>])
mbr_gid_to_uuid)
AC_CHECK_DECLS([ACL_TYPE_EXTENDED, ACL_TYPE_NFS4, ACL_USER,
ACL_SYNCHRONIZE], [], [],
@ -1328,6 +1324,7 @@ fi
if test "x$with_mbedtls" = "xyes"; then
AC_CHECK_HEADERS([mbedtls/aes.h mbedtls/md.h mbedtls/pkcs5.h])
AC_CHECK_HEADERS([mbedtls/version.h])
saved_LIBS=$LIBS
AC_CHECK_LIB(mbedcrypto,mbedtls_sha1_init)
CRYPTO_CHECK(MD5, MBEDTLS, md5)
@ -1344,6 +1341,7 @@ fi
if test "x$with_nettle" = "xyes"; then
AC_CHECK_HEADERS([nettle/md5.h nettle/ripemd160.h nettle/sha.h])
AC_CHECK_HEADERS([nettle/pbkdf2.h nettle/aes.h nettle/hmac.h])
AC_CHECK_HEADERS([nettle/version.h])
saved_LIBS=$LIBS
AC_CHECK_LIB(nettle,nettle_sha1_init)
CRYPTO_CHECK(MD5, NETTLE, md5)
@ -1358,7 +1356,7 @@ if test "x$with_nettle" = "xyes"; then
fi
if test "x$with_openssl" != "xno"; then
AC_CHECK_HEADERS([openssl/evp.h])
AC_CHECK_HEADERS([openssl/evp.h openssl/opensslv.h])
saved_LIBS=$LIBS
LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }libcrypto"
AC_CHECK_LIB(crypto,OPENSSL_config)

View File

@ -26,6 +26,8 @@ LOCAL_PATH := $(subst /contrib/android,,$(call my-dir))
libarchive_target_config := contrib/android/config/android.h
libarchive_src_files := libarchive/archive_acl.c \
libarchive/archive_blake2s_ref.c \
libarchive/archive_blake2sp_ref.c \
libarchive/archive_check_magic.c \
libarchive/archive_cmdline.c \
libarchive/archive_cryptor.c \
@ -37,13 +39,14 @@ libarchive_src_files := libarchive/archive_acl.c \
libarchive/archive_entry_stat.c \
libarchive/archive_entry_strmode.c \
libarchive/archive_entry_xattr.c \
libarchive/archive_getdate.c \
libarchive/archive_hmac.c \
libarchive/archive_match.c \
libarchive/archive_options.c \
libarchive/archive_pack_dev.c \
libarchive/archive_parse_date.c \
libarchive/archive_pathmatch.c \
libarchive/archive_ppmd7.c \
libarchive/archive_ppmd8.c \
libarchive/archive_random.c \
libarchive/archive_rb.c \
libarchive/archive_read.c \
@ -86,6 +89,7 @@ libarchive_src_files := libarchive/archive_acl.c \
libarchive/archive_read_support_format_lha.c \
libarchive/archive_read_support_format_mtree.c \
libarchive/archive_read_support_format_rar.c \
libarchive/archive_read_support_format_rar5.c \
libarchive/archive_read_support_format_raw.c \
libarchive/archive_read_support_format_tar.c \
libarchive/archive_read_support_format_warc.c \
@ -93,6 +97,7 @@ libarchive_src_files := libarchive/archive_acl.c \
libarchive/archive_read_support_format_zip.c \
libarchive/archive_string.c \
libarchive/archive_string_sprintf.c \
libarchive/archive_time.c \
libarchive/archive_util.c \
libarchive/archive_version_details.c \
libarchive/archive_virtual.c \
@ -123,7 +128,9 @@ libarchive_src_files := libarchive/archive_acl.c \
libarchive/archive_write_set_format_ar.c \
libarchive/archive_write_set_format_by_name.c \
libarchive/archive_write_set_format_cpio.c \
libarchive/archive_write_set_format_cpio_binary.c \
libarchive/archive_write_set_format_cpio_newc.c \
libarchive/archive_write_set_format_cpio_odc.c \
libarchive/archive_write_set_format_iso9660.c \
libarchive/archive_write_set_format_mtree.c \
libarchive/archive_write_set_format_pax.c \
@ -151,7 +158,7 @@ else
libarchive_host_src_files :=
endif
libarchive_fe_src_files := libarchive_fe/err.c \
libarchive_fe_src_files := libarchive_fe/lafe_err.c \
libarchive_fe/line_reader.c \
libarchive_fe/passphrase.c
@ -305,4 +312,17 @@ LOCAL_SRC_FILES := $(bsdcat_src_files)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/libarchive $(LOCAL_PATH)/libarchive_fe $(LOCAL_PATH)/contrib/android/include
include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_MODULE := bsdtar-recovery
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_STEM := bsdtar
LOCAL_CFLAGS := -DBSDTAR_VERSION_STRING=ARCHIVE_VERSION_ONLY_STRING -DPLATFORM_CONFIG_H=\"$(libarchive_target_config)\"
LOCAL_STATIC_LIBRARIES := libarchive libarchive_fe libz
LOCAL_SRC_FILES := $(bsdtar_src_files)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/libarchive $(LOCAL_PATH)/libarchive_fe $(LOCAL_PATH)/contrib/android/include
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_FORCE_STATIC_EXECUTABLE := true
include $(BUILD_EXECUTABLE)
endif

View File

@ -26,6 +26,8 @@
#ifndef ARCHIVE_PLATFORM_H_ANDROID_INCLUDED
#define ARCHIVE_PLATFORM_H_ANDROID_INCLUDED
#define __LIBARCHIVE_CONFIG_H_INCLUDED 1
#include <android/api-level.h>
#ifdef __ANDROID_API__
#if __ANDROID_API__ > 20
@ -40,6 +42,8 @@
#define HAVE_CHOWN 1
#define HAVE_CHROOT 1
#define HAVE_CLOSEFROM 0
#define HAVE_CLOSE_RANGE 0
#define HAVE_CTIME_R 1
#define HAVE_CTYPE_H 1
#define HAVE_DECL_EXTATTR_NAMESPACE_USER 0
@ -53,6 +57,8 @@
#define HAVE_DECL_UINTMAX_MAX 1
#define HAVE_DECL_UINT32_MAX 1
#define HAVE_DECL_UINT64_MAX 1
#define HAVE_DECL_INT32_MAX 1
#define HAVE_DECL_INT32_MIN 1
#define HAVE_DIRENT_H 1
#define HAVE_DIRFD 1
#define HAVE_DLFCN_H 1
@ -135,7 +141,7 @@
#define HAVE_STRING_H 1
#define HAVE_STRRCHR 1
#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
#define HAVE_STRUCT_STAT_ST_MTIME_NSEC 1
#define HAVE_STRUCT_STAT_ST_MTIME_NSEC 0
#define HAVE_STRUCT_TM_TM_GMTOFF 1
#define HAVE_SYMLINK 1
#define HAVE_SYS_CDEFS_H 1
@ -151,6 +157,8 @@
#define HAVE_SYS_UTSNAME_H 1
#define HAVE_SYS_VFS_H 1
#define HAVE_SYS_WAIT_H 1
#define HAVE_TCGETATTR 1
#define HAVE_TCSETATTR 1
#define HAVE_TIME_H 1
#define HAVE_TZSET 1
#define HAVE_UINTMAX_T 1

View File

@ -28,6 +28,8 @@
#define HAVE_CHOWN 1
#define HAVE_CHROOT 1
#define HAVE_CLOSEFROM 1
#define HAVE_CLOSE_RANGE 1
#define HAVE_CTIME_R 1
#define HAVE_CTYPE_H 1
#define HAVE_DECL_EXTATTR_NAMESPACE_USER 0
@ -153,6 +155,8 @@
#define HAVE_SYS_VFS_H 1
#define HAVE_SYS_WAIT_H 1
#define HAVE_SYS_XATTR_H 1
#define HAVE_TCGETATTR 1
#define HAVE_TCSETATTR 1
#define HAVE_TIMEGM 1
#define HAVE_TIME_H 1
#define HAVE_TZSET 1
@ -178,7 +182,7 @@
#define HAVE_WMEMCMP 1
#define HAVE_WMEMCPY 1
#define HAVE_ZLIB_H 1
#define ICONV_CONST
#define ICONV_CONST
#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
#define SIZEOF_WCHAR_T 4
#define STDC_HEADERS 1

View File

@ -175,6 +175,12 @@
/* Define to 1 if you have the `chroot' function. */
/* #undef HAVE_CHROOT */
/* Define to 1 if you have the `closefrom' function. */
/* #undef HAVE_CLOSEFROM */
/* Define to 1 if you have the `close_range' function. */
/* #undef HAVE_CLOSE_RANGE */
/* Define to 1 if you have the <copyfile.h> header file. */
/* #undef HAVE_COPYFILE_H */
@ -530,9 +536,6 @@
/* Define to 1 if you have the <lz4.h> header file. */
/* #undef HAVE_LZ4_H */
/* Define to 1 if you have the <lzmadec.h> header file. */
/* #undef HAVE_LZMADEC_H */
/* Define to 1 if you have the <lzma.h> header file. */
/* #undef HAVE_LZMA_H */
@ -623,9 +626,6 @@
/* Define to 1 if you have the <pwd.h> header file. */
/* #undef HAVE_PWD_H */
/* Define to 1 if you have a POSIX compatible readdir_r */
#define HAVE_READDIR_R 1
/* Define to 1 if you have the `readlink' function. */
/* #undef HAVE_READLINK */
@ -827,6 +827,12 @@
/* Define to 1 if you have the <sys/xattr.h> header file. */
/* #undef HAVE_SYS_XATTR_H */
/* Define to 1 if you have the `tcgetattr' function. */
/* #undef HAVE_TCGETATTR */
/* Define to 1 if you have the `tcsetattr' function. */
/* #undef HAVE_TCSETATTR */
/* Define to 1 if you have the `timegm' function. */
/* #undef HAVE_TIMEGM */
@ -893,9 +899,6 @@
/* Define to 1 if you have the <wctype.h> header file. */
#define HAVE_WCTYPE_H 1
/* Define to 1 if you have the <wincrypt.h> header file. */
#define HAVE_WINCRYPT_H 1
/* Define to 1 if you have the <windows.h> header file. */
#define HAVE_WINDOWS_H 1

View File

@ -1,4 +1,4 @@
/*
/*
* Macros for file64 functions
*
* Android does not support the macro _FILE_OFFSET_BITS=64
@ -19,7 +19,6 @@
#include <sys/vfs.h>
//dirent.h
#define readdir_r readdir64_r
#define readdir readdir64
#define dirent dirent64
//fcntl.h

View File

@ -22,7 +22,6 @@ BuildRequires: libzstd-devel
BuildRequires: lz4-devel
BuildRequires: lzo-devel
BuildRequires: openssl-devel
BuildRequires: sharutils
BuildRequires: xz-devel
BuildRequires: zlib-devel

View File

@ -0,0 +1,156 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef LIBARCHIVE_FUZZ_HELPERS_H_
#define LIBARCHIVE_FUZZ_HELPERS_H_
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <ftw.h>
#include <unistd.h>
#include "archive.h"
// Default maximum input size for fuzzers
static constexpr size_t kDefaultMaxInputSize = 256 * 1024; // 256KB
// Buffer structure for archive reading callbacks
struct Buffer {
const uint8_t* data;
size_t size;
size_t pos;
};
// Archive read callback function
static la_ssize_t reader_callback(struct archive* a, void* client_data,
const void** buffer) {
(void)a;
Buffer* buf = static_cast<Buffer*>(client_data);
if (buf->pos >= buf->size) {
return 0; // EOF
}
*buffer = buf->data + buf->pos;
size_t remaining = buf->size - buf->pos;
buf->pos = buf->size; // Consume all remaining data
return static_cast<la_ssize_t>(remaining);
}
// Helper class for consuming fuzz data in structured ways
class DataConsumer {
public:
DataConsumer(const uint8_t* data, size_t size)
: data_(data), size_(size), pos_(0) {}
bool empty() const { return pos_ >= size_; }
size_t remaining() const { return size_ - pos_; }
uint8_t consume_byte() {
if (pos_ >= size_) return 0;
return data_[pos_++];
}
uint16_t consume_u16() {
uint16_t val = 0;
if (pos_ + 2 <= size_) {
val = static_cast<uint16_t>(data_[pos_]) |
(static_cast<uint16_t>(data_[pos_ + 1]) << 8);
pos_ += 2;
}
return val;
}
uint32_t consume_u32() {
uint32_t val = 0;
if (pos_ + 4 <= size_) {
val = static_cast<uint32_t>(data_[pos_]) |
(static_cast<uint32_t>(data_[pos_ + 1]) << 8) |
(static_cast<uint32_t>(data_[pos_ + 2]) << 16) |
(static_cast<uint32_t>(data_[pos_ + 3]) << 24);
pos_ += 4;
}
return val;
}
int64_t consume_i64() {
int64_t val = 0;
if (pos_ + 8 <= size_) {
for (int i = 0; i < 8; i++) {
val |= static_cast<int64_t>(data_[pos_ + i]) << (8 * i);
}
pos_ += 8;
}
return val;
}
// Consume a null-terminated string up to max_len characters
// Returns pointer to internal buffer (valid until next consume_string call)
const char* consume_string(size_t max_len) {
if (max_len > sizeof(string_buf_) - 1) {
max_len = sizeof(string_buf_) - 1;
}
size_t avail = size_ - pos_;
size_t len = (avail < max_len) ? avail : max_len;
size_t actual_len = 0;
while (actual_len < len && pos_ < size_) {
char c = static_cast<char>(data_[pos_++]);
if (c == '\0') break;
string_buf_[actual_len++] = c;
}
string_buf_[actual_len] = '\0';
return string_buf_;
}
// Consume raw bytes into a buffer
size_t consume_bytes(void* out, size_t len) {
size_t avail = size_ - pos_;
size_t to_copy = (avail < len) ? avail : len;
if (to_copy > 0) {
memcpy(out, data_ + pos_, to_copy);
pos_ += to_copy;
}
return to_copy;
}
// Get remaining data as a buffer
const uint8_t* remaining_data() const {
return data_ + pos_;
}
private:
const uint8_t* data_;
size_t size_;
size_t pos_;
char string_buf_[512];
};
// Callback for nftw to remove files/directories
static int remove_callback(const char* fpath, const struct stat* sb,
int typeflag, struct FTW* ftwbuf) {
(void)sb;
(void)typeflag;
(void)ftwbuf;
return remove(fpath);
}
// Recursively remove a directory tree (safer than system("rm -rf ..."))
static int remove_directory_tree(const char* path) {
// nftw with FTW_DEPTH processes directory contents before the directory itself
return nftw(path, remove_callback, 64, FTW_DEPTH | FTW_PHYS);
}
#endif // LIBARCHIVE_FUZZ_HELPERS_H_

View File

@ -0,0 +1,63 @@
/*
* 7-Zip format specific fuzzer for libarchive
* Targets 7-Zip parsing and decompression code paths
*/
#include <stddef.h>
#include <stdint.h>
#include <vector>
#include "archive.h"
#include "archive_entry.h"
#include "fuzz_helpers.h"
static constexpr size_t kMaxInputSize = 512 * 1024; // 512KB
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
if (len == 0 || len > kMaxInputSize) {
return 0;
}
struct archive *a = archive_read_new();
if (a == NULL) {
return 0;
}
// Enable 7-Zip format specifically
archive_read_support_format_7zip(a);
// Enable all filters for 7z internal compression
archive_read_support_filter_all(a);
// Set passphrase for encrypted archives
archive_read_add_passphrase(a, "password");
Buffer buffer = {buf, len, 0};
if (archive_read_open(a, &buffer, NULL, reader_callback, NULL) != ARCHIVE_OK) {
archive_read_free(a);
return 0;
}
std::vector<uint8_t> data_buffer(4096, 0);
struct archive_entry *entry;
while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
// Exercise entry metadata access
archive_entry_pathname(entry);
archive_entry_pathname_w(entry);
archive_entry_size(entry);
archive_entry_mtime(entry);
archive_entry_mode(entry);
archive_entry_is_encrypted(entry);
archive_entry_is_data_encrypted(entry);
archive_entry_is_metadata_encrypted(entry);
// Read data
ssize_t r;
while ((r = archive_read_data(a, data_buffer.data(), data_buffer.size())) > 0)
;
}
archive_read_free(a);
return 0;
}

View File

@ -0,0 +1,47 @@
# 7-Zip format dictionary
# Magic bytes
"7z\xbc\xaf\x27\x1c"
"\x37\x7a\xbc\xaf\x27\x1c"
# Common property IDs
"\x00"
"\x01"
"\x02"
"\x03"
"\x04"
"\x05"
"\x06"
"\x07"
"\x08"
"\x09"
"\x0a"
"\x0b"
"\x0c"
"\x0d"
"\x0e"
"\x0f"
"\x10"
"\x11"
"\x17"
"\x19"
"\x21"
"\x23"
"\x24"
"\x25"
# Compression method IDs
"\x00\x00"
"\x00\x03"
"\x00\x04"
"\x00\x06"
"\x01\x01"
"\x03\x01\x01"
"\x04\x01\x08"
"\x04\x02\x02"
"\x21\x01"
"\x30\x01\x01"
# Encryption
"\x06\xf1\x07\x01"
"Password"
"password"

View File

@ -0,0 +1,10 @@
[libfuzzer]
max_len = 524288
timeout = 60
rss_limit_mb = 2048
[honggfuzz]
timeout = 60
[afl]
timeout = 60

View File

@ -0,0 +1,54 @@
/*
* AR (Unix archive) format fuzzer for libarchive
* Tests BSD and GNU ar formats
*/
#include <stddef.h>
#include <stdint.h>
#include <vector>
#include "archive.h"
#include "archive_entry.h"
#include "fuzz_helpers.h"
static constexpr size_t kMaxInputSize = 512 * 1024;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
if (len == 0 || len > kMaxInputSize) {
return 0;
}
struct archive *a = archive_read_new();
if (a == NULL) {
return 0;
}
archive_read_support_format_ar(a);
archive_read_support_filter_all(a);
Buffer buffer = {buf, len, 0};
if (archive_read_open(a, &buffer, NULL, reader_callback, NULL) != ARCHIVE_OK) {
archive_read_free(a);
return 0;
}
std::vector<uint8_t> data_buffer(4096, 0);
struct archive_entry *entry;
while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
archive_entry_pathname(entry);
archive_entry_size(entry);
archive_entry_mtime(entry);
archive_entry_mode(entry);
archive_entry_uid(entry);
archive_entry_gid(entry);
ssize_t r;
while ((r = archive_read_data(a, data_buffer.data(), data_buffer.size())) > 0)
;
}
archive_read_free(a);
return 0;
}

View File

@ -0,0 +1,20 @@
# AR format dictionary
# AR magic
"!<arch>\x0a"
# File header terminator
"\x60\x0a"
# Special entries
"/"
"//"
"/SYM64/"
# Common permissions
"100644 "
"100755 "
# UID/GID fields
"0 "
"1000 "

View File

@ -0,0 +1,51 @@
/*
* CAB (Microsoft Cabinet) format fuzzer for libarchive
*/
#include <stddef.h>
#include <stdint.h>
#include <vector>
#include "archive.h"
#include "archive_entry.h"
#include "fuzz_helpers.h"
static constexpr size_t kMaxInputSize = 512 * 1024;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
if (len == 0 || len > kMaxInputSize) {
return 0;
}
struct archive *a = archive_read_new();
if (a == NULL) {
return 0;
}
archive_read_support_format_cab(a);
archive_read_support_filter_all(a);
Buffer buffer = {buf, len, 0};
if (archive_read_open(a, &buffer, NULL, reader_callback, NULL) != ARCHIVE_OK) {
archive_read_free(a);
return 0;
}
std::vector<uint8_t> data_buffer(4096, 0);
struct archive_entry *entry;
while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
archive_entry_pathname(entry);
archive_entry_size(entry);
archive_entry_mtime(entry);
archive_entry_mode(entry);
ssize_t r;
while ((r = archive_read_data(a, data_buffer.data(), data_buffer.size())) > 0)
;
}
archive_read_free(a);
return 0;
}

View File

@ -0,0 +1,23 @@
# CAB (Microsoft Cabinet) format dictionary
# CAB signature
"MSCF"
"\x4d\x53\x43\x46"
# Version
"\x03\x01"
# Compression types
"\x00\x00"
"\x01\x00"
"\x02\x00"
"\x03\x00"
# Folder count patterns
"\x01\x00"
"\x02\x00"
# Header flags
"\x00\x00"
"\x01\x00"
"\x04\x00"

View File

@ -0,0 +1,58 @@
/*
* CPIO format fuzzer for libarchive
* Tests all CPIO variants: binary, odc, newc, crc
*/
#include <stddef.h>
#include <stdint.h>
#include <vector>
#include "archive.h"
#include "archive_entry.h"
#include "fuzz_helpers.h"
static constexpr size_t kMaxInputSize = 512 * 1024;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
if (len == 0 || len > kMaxInputSize) {
return 0;
}
struct archive *a = archive_read_new();
if (a == NULL) {
return 0;
}
archive_read_support_format_cpio(a);
archive_read_support_filter_all(a);
Buffer buffer = {buf, len, 0};
if (archive_read_open(a, &buffer, NULL, reader_callback, NULL) != ARCHIVE_OK) {
archive_read_free(a);
return 0;
}
std::vector<uint8_t> data_buffer(4096, 0);
struct archive_entry *entry;
while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
archive_entry_pathname(entry);
archive_entry_size(entry);
archive_entry_mtime(entry);
archive_entry_mode(entry);
archive_entry_uid(entry);
archive_entry_gid(entry);
archive_entry_ino(entry);
archive_entry_nlink(entry);
archive_entry_rdev(entry);
archive_entry_hardlink(entry);
ssize_t r;
while ((r = archive_read_data(a, data_buffer.data(), data_buffer.size())) > 0)
;
}
archive_read_free(a);
return 0;
}

View File

@ -0,0 +1,25 @@
# CPIO format dictionary
# Binary magic (little endian)
"\xc7\x71"
# Binary magic (big endian)
"\x71\xc7"
# ASCII odc magic
"070707"
# ASCII newc magic
"070701"
# ASCII crc magic
"070702"
# Common trailer
"TRAILER!!!"
# Common field patterns
"00000000"
"00000001"
"000001ed"
"000003e8"

View File

@ -0,0 +1,101 @@
/*
* Encrypted archive fuzzer for libarchive
* Tests password/passphrase handling across formats
*/
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <vector>
#include "archive.h"
#include "archive_entry.h"
#include "fuzz_helpers.h"
static constexpr size_t kMaxInputSize = 512 * 1024;
// Passphrase callback for testing
static const char *test_passphrases[] = {
"password",
"test",
"123456",
"",
"secret",
NULL
};
static int passphrase_idx = 0;
static const char* passphrase_callback(struct archive *a, void *client_data) {
(void)a;
(void)client_data;
const char *pass = test_passphrases[passphrase_idx];
if (pass != NULL) {
passphrase_idx++;
}
return pass;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
if (len == 0 || len > kMaxInputSize) {
return 0;
}
// Reset passphrase index
passphrase_idx = 0;
struct archive *a = archive_read_new();
if (a == NULL) {
return 0;
}
// Enable all formats that support encryption
archive_read_support_format_zip(a);
archive_read_support_format_7zip(a);
archive_read_support_format_rar(a);
archive_read_support_format_rar5(a);
archive_read_support_filter_all(a);
// Set up passphrase callback
archive_read_set_passphrase_callback(a, NULL, passphrase_callback);
// Also add some static passphrases
archive_read_add_passphrase(a, "password");
archive_read_add_passphrase(a, "test123");
Buffer buffer = {buf, len, 0};
if (archive_read_open(a, &buffer, NULL, reader_callback, NULL) != ARCHIVE_OK) {
archive_read_free(a);
return 0;
}
std::vector<uint8_t> data_buffer(4096, 0);
struct archive_entry *entry;
int entry_count = 0;
while (archive_read_next_header(a, &entry) == ARCHIVE_OK && entry_count < 100) {
archive_entry_pathname(entry);
// Check encryption status
int is_encrypted = archive_entry_is_encrypted(entry);
int is_data_encrypted = archive_entry_is_data_encrypted(entry);
int is_meta_encrypted = archive_entry_is_metadata_encrypted(entry);
(void)is_encrypted;
(void)is_data_encrypted;
(void)is_meta_encrypted;
// Check if archive has encrypted entries
archive_read_has_encrypted_entries(a);
// Try to read data (may fail due to wrong password)
ssize_t r;
while ((r = archive_read_data(a, data_buffer.data(), data_buffer.size())) > 0)
;
entry_count++;
}
archive_read_free(a);
return 0;
}

View File

@ -0,0 +1,10 @@
[libfuzzer]
max_len = 524288
timeout = 60
rss_limit_mb = 2048
[honggfuzz]
timeout = 60
[afl]
timeout = 60

View File

@ -0,0 +1,105 @@
/*
* Archive entry fuzzer for libarchive
* Targets archive_entry_* functions including ACL, linkify, and metadata
*/
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include "archive.h"
#include "archive_entry.h"
#include "fuzz_helpers.h"
static constexpr size_t kMaxInputSize = 64 * 1024; // 64KB
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
if (len == 0 || len > kMaxInputSize) {
return 0;
}
DataConsumer consumer(buf, len);
struct archive_entry *entry = archive_entry_new();
if (entry == NULL) {
return 0;
}
// Set basic entry properties
archive_entry_set_pathname(entry, consumer.consume_string(256));
archive_entry_set_size(entry, consumer.consume_i64());
archive_entry_set_mode(entry, consumer.consume_u32());
archive_entry_set_uid(entry, consumer.consume_u32());
archive_entry_set_gid(entry, consumer.consume_u32());
archive_entry_set_mtime(entry, consumer.consume_i64(), 0);
archive_entry_set_atime(entry, consumer.consume_i64(), 0);
archive_entry_set_ctime(entry, consumer.consume_i64(), 0);
archive_entry_set_birthtime(entry, consumer.consume_i64(), 0);
// Set various string fields
archive_entry_set_uname(entry, consumer.consume_string(64));
archive_entry_set_gname(entry, consumer.consume_string(64));
archive_entry_set_symlink(entry, consumer.consume_string(256));
archive_entry_set_hardlink(entry, consumer.consume_string(256));
// Exercise ACL functions (low coverage targets)
int acl_type = consumer.consume_byte() & 0x0F;
int acl_permset = consumer.consume_u32();
int acl_tag = consumer.consume_byte() & 0x0F;
int acl_qual = consumer.consume_u32();
const char *acl_name = consumer.consume_string(64);
archive_entry_acl_add_entry(entry, acl_type, acl_permset, acl_tag, acl_qual, acl_name);
// Add more ACL entries based on remaining data
while (!consumer.empty() && consumer.remaining() > 10) {
acl_type = consumer.consume_byte() & 0x0F;
acl_permset = consumer.consume_u32();
acl_tag = consumer.consume_byte() & 0x0F;
acl_qual = consumer.consume_u32();
acl_name = consumer.consume_string(32);
archive_entry_acl_add_entry(entry, acl_type, acl_permset, acl_tag, acl_qual, acl_name);
}
// Exercise ACL text conversion functions (archive_acl_to_text_* are uncovered)
ssize_t text_len;
char *acl_text = archive_entry_acl_to_text(entry, &text_len, ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
if (acl_text) {
// Parse the text back
archive_entry_acl_from_text(entry, acl_text, ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
free(acl_text);
}
acl_text = archive_entry_acl_to_text(entry, &text_len, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
if (acl_text) {
free(acl_text);
}
acl_text = archive_entry_acl_to_text(entry, &text_len, ARCHIVE_ENTRY_ACL_TYPE_NFS4);
if (acl_text) {
free(acl_text);
}
// Exercise wide character versions
wchar_t *acl_text_w = archive_entry_acl_to_text_w(entry, &text_len, ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
if (acl_text_w) {
free(acl_text_w);
}
// Get pathname variants
archive_entry_pathname(entry);
archive_entry_pathname_w(entry);
archive_entry_pathname_utf8(entry);
// Clone the entry
struct archive_entry *entry2 = archive_entry_clone(entry);
if (entry2) {
archive_entry_free(entry2);
}
// Clear and reuse
archive_entry_clear(entry);
archive_entry_free(entry);
return 0;
}

View File

@ -0,0 +1,65 @@
/*
* Compression filter fuzzer for libarchive
* Tests decompression of gzip, bzip2, xz, lzma, zstd, lz4, etc.
*/
#include <stddef.h>
#include <stdint.h>
#include <vector>
#include "archive.h"
#include "archive_entry.h"
#include "fuzz_helpers.h"
static constexpr size_t kMaxInputSize = 256 * 1024;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
if (len == 0 || len > kMaxInputSize) {
return 0;
}
struct archive *a = archive_read_new();
if (a == NULL) {
return 0;
}
// Enable raw format (just decompress, no archive format)
archive_read_support_format_raw(a);
// Enable all compression filters
archive_read_support_filter_all(a);
Buffer buffer = {buf, len, 0};
if (archive_read_open(a, &buffer, NULL, reader_callback, NULL) != ARCHIVE_OK) {
archive_read_free(a);
return 0;
}
std::vector<uint8_t> data_buffer(8192, 0);
struct archive_entry *entry;
if (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
// Get filter info
int filter_count = archive_filter_count(a);
for (int i = 0; i < filter_count; i++) {
archive_filter_name(a, i);
archive_filter_code(a, i);
archive_filter_bytes(a, i);
}
// Read all decompressed data
ssize_t total = 0;
ssize_t r;
while ((r = archive_read_data(a, data_buffer.data(), data_buffer.size())) > 0) {
total += r;
// Limit total decompressed size to prevent zip bombs
if (total > 10 * 1024 * 1024) {
break;
}
}
}
archive_read_free(a);
return 0;
}

View File

@ -0,0 +1,33 @@
# Compression filter dictionary
# GZIP magic
"\x1f\x8b"
"\x1f\x8b\x08"
# BZIP2 magic
"BZh"
"BZ0"
# XZ magic
"\xfd7zXZ\x00"
# LZMA magic
"\x5d\x00\x00"
# ZSTD magic
"\x28\xb5\x2f\xfd"
# LZ4 magic
"\x04\x22\x4d\x18"
# Compress (.Z) magic
"\x1f\x9d"
# LZIP magic
"LZIP"
# LRZIP magic
"LRZI"
# LZO magic
"\x89LZO\x00\x0d\x0a\x1a\x0a"

View File

@ -0,0 +1,10 @@
[libfuzzer]
max_len = 262144
timeout = 30
rss_limit_mb = 2048
[honggfuzz]
timeout = 30
[afl]
timeout = 30

View File

@ -3,20 +3,7 @@
#include <vector>
#include "archive.h"
struct Buffer {
const uint8_t *buf;
size_t len;
};
ssize_t reader_callback(struct archive *a, void *client_data,
const void **block) {
Buffer *buffer = reinterpret_cast<Buffer *>(client_data);
*block = buffer->buf;
ssize_t len = buffer->len;
buffer->len = 0;
return len;
}
#include "fuzz_helpers.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
int ret;
@ -26,7 +13,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
archive_read_support_filter_all(a);
archive_read_support_format_all(a);
Buffer buffer = {buf, len};
Buffer buffer = {buf, len, 0};
archive_read_open(a, &buffer, NULL, reader_callback, NULL);
std::vector<uint8_t> data_buffer(getpagesize(), 0);

View File

@ -0,0 +1,76 @@
# General libarchive dictionary covering multiple formats
# TAR magic
"ustar"
"ustar\x00"
"ustar \x00"
"\x00\x00"
# ZIP magic
"PK\x03\x04"
"PK\x05\x06"
"PK\x01\x02"
"PK\x07\x08"
# 7z magic
"7z\xbc\xaf\x27\x1c"
# RAR magic
"Rar!\x1a\x07\x00"
"Rar!\x1a\x07\x01\x00"
# XAR magic
"xar!"
# CPIO magic
"\xc7\x71"
"070701"
"070702"
"070707"
# CAB magic
"MSCF"
# LHA magic
"-lh"
"-lz"
# AR magic
"!<arch>\x0a"
# ISO9660 magic
"CD001"
# GZIP magic
"\x1f\x8b"
# BZIP2 magic
"BZ"
"BZh"
# XZ magic
"\xfd7zXZ\x00"
# LZMA magic
"\x5d\x00\x00"
# ZSTD magic
"\x28\xb5\x2f\xfd"
# LZ4 magic
"\x04\x22\x4d\x18"
# Common paths
"/"
"./"
"../"
"./test"
"test.txt"
"test/"
# Common attributes
"\x00\x00\x00\x00"
"\xff\xff\xff\xff"
# Passphrase
"password"

View File

@ -0,0 +1,9 @@
[libfuzzer]
max_len = 524288
timeout = 30
[honggfuzz]
timeout = 30
[afl]
timeout = 30

View File

@ -0,0 +1,58 @@
/*
* ISO9660 format fuzzer for libarchive
* Tests ISO, Joliet, and Rock Ridge extensions
*/
#include <stddef.h>
#include <stdint.h>
#include <vector>
#include "archive.h"
#include "archive_entry.h"
#include "fuzz_helpers.h"
static constexpr size_t kMaxInputSize = 1024 * 1024; // 1MB for ISO images
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
if (len == 0 || len > kMaxInputSize) {
return 0;
}
struct archive *a = archive_read_new();
if (a == NULL) {
return 0;
}
archive_read_support_format_iso9660(a);
archive_read_support_filter_all(a);
// Set options to test various ISO extensions
archive_read_set_options(a, "iso9660:joliet,iso9660:rockridge");
Buffer buffer = {buf, len, 0};
if (archive_read_open(a, &buffer, NULL, reader_callback, NULL) != ARCHIVE_OK) {
archive_read_free(a);
return 0;
}
std::vector<uint8_t> data_buffer(4096, 0);
struct archive_entry *entry;
while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
archive_entry_pathname(entry);
archive_entry_pathname_w(entry);
archive_entry_size(entry);
archive_entry_mtime(entry);
archive_entry_mode(entry);
archive_entry_symlink(entry);
archive_entry_hardlink(entry);
ssize_t r;
while ((r = archive_read_data(a, data_buffer.data(), data_buffer.size())) > 0)
;
}
archive_read_free(a);
return 0;
}

View File

@ -0,0 +1,36 @@
# ISO9660 format dictionary
# Volume descriptor type
"\x00"
"\x01"
"\x02"
"\xff"
# Standard identifier
"CD001"
# Volume descriptor version
"\x01"
# Joliet escape sequences
"%/@"
"%/C"
"%/E"
# Rock Ridge signatures
"SP"
"RR"
"CE"
"PX"
"PN"
"SL"
"NM"
"CL"
"PL"
"RE"
"TF"
"SF"
# System use
"ER"
"ES"

View File

@ -0,0 +1,10 @@
[libfuzzer]
max_len = 1048576
timeout = 60
rss_limit_mb = 2048
[honggfuzz]
timeout = 60
[afl]
timeout = 60

View File

@ -0,0 +1,54 @@
/*
* LHA/LZH format fuzzer for libarchive
*/
#include <stddef.h>
#include <stdint.h>
#include <vector>
#include "archive.h"
#include "archive_entry.h"
#include "fuzz_helpers.h"
static constexpr size_t kMaxInputSize = 512 * 1024;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
if (len == 0 || len > kMaxInputSize) {
return 0;
}
struct archive *a = archive_read_new();
if (a == NULL) {
return 0;
}
archive_read_support_format_lha(a);
archive_read_support_filter_all(a);
Buffer buffer = {buf, len, 0};
if (archive_read_open(a, &buffer, NULL, reader_callback, NULL) != ARCHIVE_OK) {
archive_read_free(a);
return 0;
}
std::vector<uint8_t> data_buffer(4096, 0);
struct archive_entry *entry;
while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
archive_entry_pathname(entry);
archive_entry_pathname_w(entry);
archive_entry_size(entry);
archive_entry_mtime(entry);
archive_entry_mode(entry);
archive_entry_uid(entry);
archive_entry_gid(entry);
ssize_t r;
while ((r = archive_read_data(a, data_buffer.data(), data_buffer.size())) > 0)
;
}
archive_read_free(a);
return 0;
}

View File

@ -0,0 +1,26 @@
# LHA/LZH format dictionary
# Compression methods
"-lh0-"
"-lh1-"
"-lh2-"
"-lh3-"
"-lh4-"
"-lh5-"
"-lh6-"
"-lh7-"
"-lhd-"
"-lzs-"
"-lz4-"
"-lz5-"
# OS type
"\x00"
"\x4d"
"\x55"
# Header levels
"\x00"
"\x01"
"\x02"
"\x03"

View File

@ -0,0 +1,110 @@
/*
* Archive entry link resolver fuzzer for libarchive
* Targets archive_entry_linkify (complexity: 775, zero coverage)
*/
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include "archive.h"
#include "archive_entry.h"
#include "fuzz_helpers.h"
static constexpr size_t kMaxInputSize = 64 * 1024; // 64KB
// Simple data consumer
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
if (len == 0 || len > kMaxInputSize) {
return 0;
}
DataConsumer consumer(buf, len);
// Create a link resolver
struct archive_entry_linkresolver *resolver = archive_entry_linkresolver_new();
if (resolver == NULL) {
return 0;
}
// Set the format strategy based on input
uint8_t strategy = consumer.consume_byte() % 5;
int format;
switch (strategy) {
case 0: format = ARCHIVE_FORMAT_TAR_GNUTAR; break;
case 1: format = ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE; break;
case 2: format = ARCHIVE_FORMAT_CPIO_POSIX; break;
case 3: format = ARCHIVE_FORMAT_CPIO_SVR4_NOCRC; break;
default: format = ARCHIVE_FORMAT_TAR_USTAR; break;
}
archive_entry_linkresolver_set_strategy(resolver, format);
// Create multiple entries to test linkify with hardlinks
struct archive_entry *entries[32];
int num_entries = 0;
while (!consumer.empty() && num_entries < 32 && consumer.remaining() > 20) {
struct archive_entry *entry = archive_entry_new();
if (entry == NULL) break;
// Set pathname
archive_entry_set_pathname(entry, consumer.consume_string(64));
// Set inode and device for hardlink detection
archive_entry_set_ino(entry, consumer.consume_i64());
archive_entry_set_dev(entry, consumer.consume_u32());
archive_entry_set_nlink(entry, (consumer.consume_byte() % 5) + 1);
// Set mode (regular file or directory)
uint8_t ftype = consumer.consume_byte() % 2;
mode_t mode = ftype ? (S_IFDIR | 0755) : (S_IFREG | 0644);
archive_entry_set_mode(entry, mode);
archive_entry_set_size(entry, consumer.consume_i64() & 0xFFFF);
archive_entry_set_uid(entry, consumer.consume_u32() & 0xFFFF);
archive_entry_set_gid(entry, consumer.consume_u32() & 0xFFFF);
entries[num_entries++] = entry;
}
// Now run all entries through the linkresolver
for (int i = 0; i < num_entries; i++) {
struct archive_entry *entry = entries[i];
struct archive_entry *spare = NULL;
// This is the main function we want to fuzz (zero coverage)
archive_entry_linkify(resolver, &entry, &spare);
// entry and spare may be modified by linkify
// We still need to free the original entries we allocated
if (spare != NULL) {
archive_entry_free(spare);
}
}
// Free remaining entries from the resolver
struct archive_entry *entry = NULL;
struct archive_entry *spare = NULL;
while (1) {
archive_entry_linkify(resolver, &entry, &spare);
if (entry == NULL)
break;
archive_entry_free(entry);
entry = NULL;
if (spare != NULL) {
archive_entry_free(spare);
spare = NULL;
}
}
// Free all our created entries
for (int i = 0; i < num_entries; i++) {
if (entries[i] != NULL) {
archive_entry_free(entries[i]);
}
}
archive_entry_linkresolver_free(resolver);
return 0;
}

View File

@ -0,0 +1,96 @@
/*
* Archive match fuzzer for libarchive
* Tests pattern matching, time matching, and owner matching
*/
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "archive.h"
#include "archive_entry.h"
#include "fuzz_helpers.h"
static constexpr size_t kMaxInputSize = 32 * 1024;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
if (len == 0 || len > kMaxInputSize) {
return 0;
}
DataConsumer consumer(buf, len);
struct archive *match = archive_match_new();
if (match == NULL) {
return 0;
}
// Add various match patterns
while (!consumer.empty() && consumer.remaining() > 5) {
uint8_t match_type = consumer.consume_byte() % 6;
switch (match_type) {
case 0: {
// Pattern exclusion
const char *pattern = consumer.consume_string(64);
archive_match_exclude_pattern(match, pattern);
break;
}
case 1: {
// Pattern inclusion
const char *pattern = consumer.consume_string(64);
archive_match_include_pattern(match, pattern);
break;
}
case 2: {
// Time comparison (newer than)
int64_t sec = consumer.consume_i64();
int64_t nsec = consumer.consume_i64() % 1000000000;
archive_match_include_time(match, ARCHIVE_MATCH_MTIME | ARCHIVE_MATCH_NEWER,
sec, nsec);
break;
}
case 3: {
// Time comparison (older than)
int64_t sec = consumer.consume_i64();
int64_t nsec = consumer.consume_i64() % 1000000000;
archive_match_include_time(match, ARCHIVE_MATCH_MTIME | ARCHIVE_MATCH_OLDER,
sec, nsec);
break;
}
case 4: {
// UID inclusion
int64_t uid = consumer.consume_i64() & 0xFFFF;
archive_match_include_uid(match, uid);
break;
}
case 5: {
// GID inclusion
int64_t gid = consumer.consume_i64() & 0xFFFF;
archive_match_include_gid(match, gid);
break;
}
}
}
// Create a test entry and check if it matches
struct archive_entry *entry = archive_entry_new();
if (entry) {
archive_entry_set_pathname(entry, "test/file.txt");
archive_entry_set_mtime(entry, 1234567890, 0);
archive_entry_set_uid(entry, 1000);
archive_entry_set_gid(entry, 1000);
archive_entry_set_mode(entry, 0644 | 0100000); // Regular file
// Test matching
archive_match_path_excluded(match, entry);
archive_match_time_excluded(match, entry);
archive_match_owner_excluded(match, entry);
archive_match_excluded(match, entry);
archive_entry_free(entry);
}
archive_match_free(match);
return 0;
}

View File

@ -0,0 +1,61 @@
/*
* MTREE format fuzzer for libarchive
* Tests mtree manifest parsing
*/
#include <stddef.h>
#include <stdint.h>
#include <vector>
#include "archive.h"
#include "archive_entry.h"
#include "fuzz_helpers.h"
static constexpr size_t kMaxInputSize = 256 * 1024;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
if (len == 0 || len > kMaxInputSize) {
return 0;
}
struct archive *a = archive_read_new();
if (a == NULL) {
return 0;
}
archive_read_support_format_mtree(a);
archive_read_support_filter_all(a);
// Enable checkfs option to test more code paths
archive_read_set_options(a, "mtree:checkfs");
Buffer buffer = {buf, len, 0};
if (archive_read_open(a, &buffer, NULL, reader_callback, NULL) != ARCHIVE_OK) {
archive_read_free(a);
return 0;
}
std::vector<uint8_t> data_buffer(4096, 0);
struct archive_entry *entry;
while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
archive_entry_pathname(entry);
archive_entry_size(entry);
archive_entry_mtime(entry);
archive_entry_mode(entry);
archive_entry_uid(entry);
archive_entry_gid(entry);
archive_entry_uname(entry);
archive_entry_gname(entry);
archive_entry_symlink(entry);
archive_entry_fflags_text(entry);
ssize_t r;
while ((r = archive_read_data(a, data_buffer.data(), data_buffer.size())) > 0)
;
}
archive_read_free(a);
return 0;
}

View File

@ -0,0 +1,47 @@
# MTREE format dictionary
# Keywords
"/set"
"/unset"
".."
# File types
"type=file"
"type=dir"
"type=link"
"type=block"
"type=char"
"type=fifo"
"type=socket"
# Attributes
"mode="
"uid="
"gid="
"uname="
"gname="
"size="
"time="
"link="
"cksum="
"md5="
"md5digest="
"sha1="
"sha1digest="
"sha256="
"sha256digest="
"sha384="
"sha384digest="
"sha512="
"sha512digest="
"rmd160="
"rmd160digest="
"flags="
"nlink="
"inode="
"device="
"resdevice="
"contents="
"optional"
"ignore"
"nochange"

View File

@ -0,0 +1,61 @@
/*
* RAR5 format specific fuzzer for libarchive
* Targets RAR5 parsing code paths
*/
#include <stddef.h>
#include <stdint.h>
#include <vector>
#include "archive.h"
#include "archive_entry.h"
#include "fuzz_helpers.h"
static constexpr size_t kMaxInputSize = 512 * 1024; // 512KB
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
if (len == 0 || len > kMaxInputSize) {
return 0;
}
struct archive *a = archive_read_new();
if (a == NULL) {
return 0;
}
// Enable RAR5 format specifically
archive_read_support_format_rar5(a);
// Enable common filters
archive_read_support_filter_all(a);
// Set passphrase for encrypted archives
archive_read_add_passphrase(a, "password");
Buffer buffer = {buf, len, 0};
if (archive_read_open(a, &buffer, NULL, reader_callback, NULL) != ARCHIVE_OK) {
archive_read_free(a);
return 0;
}
std::vector<uint8_t> data_buffer(4096, 0);
struct archive_entry *entry;
while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
// Exercise entry metadata access
archive_entry_pathname(entry);
archive_entry_pathname_w(entry);
archive_entry_size(entry);
archive_entry_mtime(entry);
archive_entry_mode(entry);
archive_entry_is_encrypted(entry);
// Read data
ssize_t r;
while ((r = archive_read_data(a, data_buffer.data(), data_buffer.size())) > 0)
;
}
archive_read_free(a);
return 0;
}

View File

@ -0,0 +1,37 @@
# RAR5 format dictionary
# Magic bytes (RAR5 signature)
"Rar!\x1a\x07\x01\x00"
"\x52\x61\x72\x21\x1a\x07\x01\x00"
# Common header types
"\x01"
"\x02"
"\x03"
"\x04"
"\x05"
# Common flags
"\x00\x00"
"\x01\x00"
"\x02\x00"
"\x04\x00"
# Compression methods
"\x00"
"\x01"
"\x02"
"\x03"
"\x04"
"\x05"
# File attributes
"\x20\x00\x00\x00"
"\x10\x00\x00\x00"
# Encryption marker
"\x80"
"password"
"Password"
# End of archive
"\x1d\x77\x56\x51\x03\x05\x04\x00"

View File

@ -0,0 +1,56 @@
/*
* RAR v4 format fuzzer for libarchive
*/
#include <stddef.h>
#include <stdint.h>
#include <vector>
#include "archive.h"
#include "archive_entry.h"
#include "fuzz_helpers.h"
static constexpr size_t kMaxInputSize = 512 * 1024;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
if (len == 0 || len > kMaxInputSize) {
return 0;
}
struct archive *a = archive_read_new();
if (a == NULL) {
return 0;
}
archive_read_support_format_rar(a);
archive_read_support_filter_all(a);
// Add passphrase for encrypted RARs
archive_read_add_passphrase(a, "password");
Buffer buffer = {buf, len, 0};
if (archive_read_open(a, &buffer, NULL, reader_callback, NULL) != ARCHIVE_OK) {
archive_read_free(a);
return 0;
}
std::vector<uint8_t> data_buffer(4096, 0);
struct archive_entry *entry;
while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
archive_entry_pathname(entry);
archive_entry_pathname_w(entry);
archive_entry_size(entry);
archive_entry_mtime(entry);
archive_entry_mode(entry);
archive_entry_is_encrypted(entry);
ssize_t r;
while ((r = archive_read_data(a, data_buffer.data(), data_buffer.size())) > 0)
;
}
archive_read_free(a);
return 0;
}

View File

@ -0,0 +1,76 @@
/*
* Archive read disk fuzzer for libarchive
* Tests filesystem traversal and entry creation from paths
* Security-critical: path traversal, symlink handling
*/
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include "archive.h"
#include "archive_entry.h"
#include "fuzz_helpers.h"
static constexpr size_t kMaxInputSize = 16 * 1024;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
if (len == 0 || len > kMaxInputSize) {
return 0;
}
DataConsumer consumer(buf, len);
struct archive *a = archive_read_disk_new();
if (a == NULL) {
return 0;
}
// Configure disk reader behavior
uint8_t flags = consumer.consume_byte();
if (flags & 0x01) {
archive_read_disk_set_symlink_logical(a);
} else if (flags & 0x02) {
archive_read_disk_set_symlink_physical(a);
} else {
archive_read_disk_set_symlink_hybrid(a);
}
archive_read_disk_set_standard_lookup(a);
// Set behavior flags
int behavior = 0;
if (flags & 0x04) behavior |= ARCHIVE_READDISK_RESTORE_ATIME;
if (flags & 0x08) behavior |= ARCHIVE_READDISK_HONOR_NODUMP;
if (flags & 0x10) behavior |= ARCHIVE_READDISK_NO_TRAVERSE_MOUNTS;
archive_read_disk_set_behavior(a, behavior);
// Create an entry and test entry_from_file with various paths
struct archive_entry *entry = archive_entry_new();
if (entry) {
// Test with /tmp (safe, always exists)
archive_entry_copy_pathname(entry, "/tmp");
archive_read_disk_entry_from_file(a, entry, -1, NULL);
// Get entry info
archive_entry_pathname(entry);
archive_entry_size(entry);
archive_entry_mode(entry);
archive_entry_uid(entry);
archive_entry_gid(entry);
// Test name lookups
archive_read_disk_gname(a, 0);
archive_read_disk_uname(a, 0);
archive_read_disk_gname(a, 1000);
archive_read_disk_uname(a, 1000);
archive_entry_free(entry);
}
archive_read_free(a);
return 0;
}

View File

@ -0,0 +1,110 @@
/*
* Archive roundtrip fuzzer for libarchive
* Writes an archive then reads it back - tests write/read consistency
*/
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include "archive.h"
#include "archive_entry.h"
#include "fuzz_helpers.h"
static constexpr size_t kMaxInputSize = 64 * 1024;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
if (len < 10 || len > kMaxInputSize) {
return 0;
}
DataConsumer consumer(buf, len);
std::vector<uint8_t> archive_data;
archive_data.reserve(len * 2);
// Phase 1: Write an archive
struct archive *writer = archive_write_new();
if (writer == NULL) {
return 0;
}
// Select format
uint8_t format = consumer.consume_byte() % 5;
switch (format) {
case 0: archive_write_set_format_pax_restricted(writer); break;
case 1: archive_write_set_format_ustar(writer); break;
case 2: archive_write_set_format_cpio_newc(writer); break;
case 3: archive_write_set_format_zip(writer); break;
default: archive_write_set_format_gnutar(writer); break;
}
archive_write_add_filter_none(writer);
// Open to memory
size_t used = 0;
archive_data.resize(len * 4);
if (archive_write_open_memory(writer, archive_data.data(), archive_data.size(), &used) != ARCHIVE_OK) {
archive_write_free(writer);
return 0;
}
// Write entries
int entry_count = 0;
while (!consumer.empty() && entry_count < 5 && consumer.remaining() > 10) {
struct archive_entry *entry = archive_entry_new();
if (entry == NULL) break;
archive_entry_set_pathname(entry, consumer.consume_string(32));
archive_entry_set_mode(entry, S_IFREG | 0644);
archive_entry_set_uid(entry, consumer.consume_u32() & 0xFFFF);
archive_entry_set_gid(entry, consumer.consume_u32() & 0xFFFF);
uint8_t data_buf[256];
size_t data_len = consumer.consume_bytes(data_buf, 256);
archive_entry_set_size(entry, data_len);
if (archive_write_header(writer, entry) == ARCHIVE_OK && data_len > 0) {
archive_write_data(writer, data_buf, data_len);
}
archive_entry_free(entry);
entry_count++;
}
archive_write_close(writer);
archive_write_free(writer);
if (used == 0) {
return 0;
}
// Phase 2: Read the archive back
struct archive *reader = archive_read_new();
if (reader == NULL) {
return 0;
}
archive_read_support_format_all(reader);
archive_read_support_filter_all(reader);
if (archive_read_open_memory(reader, archive_data.data(), used) != ARCHIVE_OK) {
archive_read_free(reader);
return 0;
}
std::vector<uint8_t> read_buffer(4096, 0);
struct archive_entry *entry;
while (archive_read_next_header(reader, &entry) == ARCHIVE_OK) {
archive_entry_pathname(entry);
archive_entry_size(entry);
ssize_t r;
while ((r = archive_read_data(reader, read_buffer.data(), read_buffer.size())) > 0)
;
}
archive_read_free(reader);
return 0;
}

View File

@ -0,0 +1,3 @@
[libfuzzer]
max_len = 65536
timeout = 30

View File

@ -0,0 +1,125 @@
/*
* Archive seek/read fuzzer for libarchive
* Tests seeking within archives and reading at random positions
*/
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <vector>
#include "archive.h"
#include "archive_entry.h"
#include "fuzz_helpers.h"
static constexpr size_t kMaxInputSize = 256 * 1024;
struct SeekableBuffer {
const uint8_t *buf;
size_t len;
size_t pos;
};
static ssize_t seek_read_callback(struct archive *a, void *client_data,
const void **block) {
(void)a;
SeekableBuffer *buffer = reinterpret_cast<SeekableBuffer *>(client_data);
if (buffer->pos >= buffer->len) {
*block = NULL;
return 0;
}
*block = buffer->buf + buffer->pos;
size_t avail = buffer->len - buffer->pos;
size_t to_read = (avail > 4096) ? 4096 : avail;
buffer->pos += to_read;
return to_read;
}
static la_int64_t seek_callback(struct archive *a, void *client_data,
la_int64_t offset, int whence) {
(void)a;
SeekableBuffer *buffer = reinterpret_cast<SeekableBuffer *>(client_data);
la_int64_t new_pos;
switch (whence) {
case SEEK_SET:
new_pos = offset;
break;
case SEEK_CUR:
new_pos = static_cast<la_int64_t>(buffer->pos) + offset;
break;
case SEEK_END:
new_pos = static_cast<la_int64_t>(buffer->len) + offset;
break;
default:
return ARCHIVE_FATAL;
}
if (new_pos < 0) new_pos = 0;
if (new_pos > static_cast<la_int64_t>(buffer->len))
new_pos = static_cast<la_int64_t>(buffer->len);
buffer->pos = static_cast<size_t>(new_pos);
return new_pos;
}
static la_int64_t skip_callback(struct archive *a, void *client_data,
la_int64_t request) {
(void)a;
SeekableBuffer *buffer = reinterpret_cast<SeekableBuffer *>(client_data);
size_t avail = buffer->len - buffer->pos;
la_int64_t to_skip = (request > static_cast<la_int64_t>(avail))
? static_cast<la_int64_t>(avail)
: request;
buffer->pos += static_cast<size_t>(to_skip);
return to_skip;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
if (len == 0 || len > kMaxInputSize) {
return 0;
}
struct archive *a = archive_read_new();
if (a == NULL) {
return 0;
}
// Enable formats that benefit from seeking
archive_read_support_format_zip_seekable(a);
archive_read_support_format_7zip(a);
archive_read_support_format_rar(a);
archive_read_support_format_rar5(a);
archive_read_support_format_iso9660(a);
archive_read_support_filter_all(a);
SeekableBuffer buffer = {buf, len, 0};
archive_read_set_read_callback(a, seek_read_callback);
archive_read_set_seek_callback(a, seek_callback);
archive_read_set_skip_callback(a, skip_callback);
archive_read_set_callback_data(a, &buffer);
if (archive_read_open1(a) != ARCHIVE_OK) {
archive_read_free(a);
return 0;
}
std::vector<uint8_t> data_buffer(4096, 0);
struct archive_entry *entry;
int entry_count = 0;
while (archive_read_next_header(a, &entry) == ARCHIVE_OK && entry_count < 50) {
archive_entry_pathname(entry);
archive_entry_size(entry);
// Read data which may trigger seeks
ssize_t r;
while ((r = archive_read_data(a, data_buffer.data(), data_buffer.size())) > 0)
;
entry_count++;
}
archive_read_free(a);
return 0;
}

Some files were not shown because too many files have changed in this diff Show More