]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
5 days agoGuard against invalid type arguments 2704/head
Tim Kientzle [Sat, 26 Jul 2025 18:10:24 +0000 (11:10 -0700)] 
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.

3 months agowarc: Prevent signed integer overflow (#2568)
Tobias Stoeckmann [Sun, 6 Apr 2025 22:24:13 +0000 (00:24 +0200)] 
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>
3 months agoFix #endif comments for header guards (#2567)
Graham Percival [Sun, 6 Apr 2025 21:16:24 +0000 (14:16 -0700)] 
Fix #endif comments for header guards (#2567)

3 months agoUse __LA_MODE_T to avoid implicit int conversions (#2478)
Graham Percival [Sun, 6 Apr 2025 21:13:17 +0000 (14:13 -0700)] 
Use __LA_MODE_T to avoid implicit int conversions (#2478)

3 months agoFix missing newline at EOF (#2566)
Graham Percival [Sun, 6 Apr 2025 20:38:06 +0000 (13:38 -0700)] 
Fix missing newline at EOF (#2566)

3 months agoImprove lseek handling (#2564)
Tobias Stoeckmann [Sun, 6 Apr 2025 20:34:37 +0000 (22:34 +0200)] 
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>
3 months agoReject bad hex values in xar checksums (#2479)
Graham Percival [Sun, 6 Apr 2025 07:29:16 +0000 (00:29 -0700)] 
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.

3 months agoUse explicit casts for some functions (#2480)
Graham Percival [Sun, 6 Apr 2025 07:26:53 +0000 (00:26 -0700)] 
Use explicit casts for some functions (#2480)

4 months agoIssue 2548: Reading GNU sparse entries (#2558)
Tim Kientzle [Sun, 30 Mar 2025 16:26:25 +0000 (09:26 -0700)] 
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

4 months ago[cmake] Require CMake 3.17 or newer (#2556)
Christoph Grüninger [Sat, 29 Mar 2025 01:06:15 +0000 (02:06 +0100)] 
[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

4 months agoCommonalising time-related functions. (#2553)
ARJANEN Loïc Jean David [Fri, 28 Mar 2025 14:23:43 +0000 (15:23 +0100)] 
Commonalising time-related functions. (#2553)

Putting the time format conversion functions in one file and using the
common functions in the various formats.

4 months ago[cmake] Require minimum CMake version of 3.5 (#2555)
Christoph Grüninger [Wed, 26 Mar 2025 13:18:12 +0000 (14:18 +0100)] 
[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.

4 months agoFix for the ZIP large file test (#2552)
ARJANEN Loïc Jean David [Tue, 25 Mar 2025 02:20:21 +0000 (03:20 +0100)] 
Fix for the ZIP large file test (#2552)

Making the ZIP large file test use the utility functions too.

4 months agoCMake: Replace CMAKE_COMPILER_IS_GNUCC with CMAKE_C_COMPILER_ID (#2550)
Peter Kokot [Sat, 22 Mar 2025 21:21:38 +0000 (22:21 +0100)] 
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.

4 months agoOnly use S_ISSOCK if available. (#2543)
nia [Tue, 18 Mar 2025 13:17:03 +0000 (14:17 +0100)] 
Only use S_ISSOCK if available. (#2543)

Needed to build on OpenServer 5 Definitive 2018.

4 months agoMove archive_entry_set_digest() to public API (#2540)
Nicholas Vinson [Sun, 16 Mar 2025 23:37:47 +0000 (19:37 -0400)] 
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.

4 months agoRemove extra newline from error messages (#2541)
Tobias Stoeckmann [Sun, 16 Mar 2025 22:33:05 +0000 (23:33 +0100)] 
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>
4 months agoFILE* seeking support (#2539)
ljdarj [Sat, 15 Mar 2025 18:17:27 +0000 (19:17 +0100)] 
FILE* seeking support (#2539)

Adding a seeker function to archive_read_open_FILE().

Fixes #437.

4 months agoCI: Update FreeBSD build environments (#2534)
Martin Matuška [Tue, 11 Mar 2025 13:15:49 +0000 (14:15 +0100)] 
CI: Update FreeBSD build environments (#2534)

FreeBSD 13.4 -> 13.5
FreeBSD 14.1 -> 14.2

4 months agofix CVE-2025-1632 and CVE-2025-25724 (#2532)
Peter Kästle [Mon, 10 Mar 2025 15:43:04 +0000 (16:43 +0100)] 
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>
4 months agoarchive_version_details' update (#2349)
ljdarj [Sat, 8 Mar 2025 03:28:51 +0000 (04:28 +0100)] 
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.

4 months agoMoving the tests' CRC-32 function to test_utils. (#2390)
ljdarj [Sat, 8 Mar 2025 03:21:23 +0000 (04:21 +0100)] 
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.

5 months agoAvoid unreachable code in this test (#2528)
Tim Kientzle [Sat, 1 Mar 2025 17:06:31 +0000 (09:06 -0800)] 
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.)

5 months agoHandle ARCHIVE_FILTER_LZOP in archive_read_append_filter (#2519)
François Degros [Mon, 24 Feb 2025 15:01:39 +0000 (02:01 +1100)] 
Handle ARCHIVE_FILTER_LZOP in archive_read_append_filter (#2519)

Fixes #2513

5 months agoFixing up archive_read_format's man page. (#2518)
ljdarj [Sat, 22 Feb 2025 17:06:28 +0000 (18:06 +0100)] 
Fixing up archive_read_format's man page. (#2518)

Adding the requested updates to the man pages.

Fixes libarchive#2507.

6 months agoRemove dev_t and time_t from public API in 4.0 (#2392)
ljdarj [Sat, 25 Jan 2025 18:14:42 +0000 (19:14 +0100)] 
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 .

6 months agoCast (mode_t)mode for POSIX functions (#2476)
Graham Percival [Tue, 7 Jan 2025 00:44:40 +0000 (16:44 -0800)] 
Cast (mode_t)mode for POSIX functions (#2476)

6 months agoFix another GCC version detection error (#2474)
Mostyn Bramley-Moore [Wed, 1 Jan 2025 23:36:17 +0000 (00:36 +0100)] 
Fix another GCC version detection error (#2474)

This is another instance of the same bug that was fixed in #2472.

6 months agoSuppress macOS CC_MD5_* deprecation warnings in the autoconf build too (#2473)
Mostyn Bramley-Moore [Wed, 1 Jan 2025 23:30:37 +0000 (00:30 +0100)] 
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.

6 months agoFix GCC version detection for __attribute__((deprecated)) (#2472)
Sam James [Wed, 1 Jan 2025 18:56:51 +0000 (18:56 +0000)] 
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
6 months agoFix a Y2038 bug by replacing `Int32x32To64` with regular multiplication (#2471)
Silent [Wed, 1 Jan 2025 16:31:35 +0000 (17:31 +0100)] 
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.

6 months agoFix compiler nitpicks (#2470)
Graham Percival [Tue, 31 Dec 2024 03:42:04 +0000 (19:42 -0800)] 
Fix compiler nitpicks (#2470)

7 months agoFix compiler nitpicks (#2469)
Graham Percival [Mon, 30 Dec 2024 21:31:48 +0000 (13:31 -0800)] 
Fix compiler nitpicks (#2469)

7 months agoFix MSVC conversion from DWORD to short warning (#2468)
Mostyn Bramley-Moore [Mon, 30 Dec 2024 16:32:39 +0000 (17:32 +0100)] 
Fix MSVC conversion from DWORD to short warning (#2468)

7 months agoFix MSVC zstd conversion from size_t to int warnings (#2467)
Mostyn Bramley-Moore [Mon, 30 Dec 2024 16:32:01 +0000 (17:32 +0100)] 
Fix MSVC zstd conversion from size_t to int warnings (#2467)

7 months agoDetect endianness at build time for common MSVC targets also (#2466)
Mostyn Bramley-Moore [Mon, 30 Dec 2024 16:31:14 +0000 (17:31 +0100)] 
Detect endianness at build time for common MSVC targets also (#2466)

This should now cover the most common build targets.

7 months agoFix compiler nitpicks (#2465)
Graham Percival [Mon, 30 Dec 2024 16:30:42 +0000 (08:30 -0800)] 
Fix compiler nitpicks (#2465)

7 months agoPrefer build-time endianness detection (#2464)
Mostyn Bramley-Moore [Mon, 30 Dec 2024 02:10:23 +0000 (03:10 +0100)] 
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.

7 months agoAdd more casts for %c, %o, and %x (#2463)
Graham Percival [Sun, 29 Dec 2024 18:20:24 +0000 (10:20 -0800)] 
Add more casts for %c, %o, and %x (#2463)

7 months agoSpelling fixes for func, struct, and macros (#2462)
Graham Percival [Sun, 29 Dec 2024 18:19:21 +0000 (10:19 -0800)] 
Spelling fixes for func, struct, and macros (#2462)

7 months agoAdd more casts for %o (#2461)
Graham Percival [Sun, 29 Dec 2024 18:18:06 +0000 (10:18 -0800)] 
Add more casts for %o (#2461)

7 months agoAdd straightforward casts for %o and %x (#2458)
Graham Percival [Sun, 29 Dec 2024 00:29:47 +0000 (16:29 -0800)] 
Add straightforward casts for %o and %x (#2458)

7 months ago7zip reader: add support for POWERPC filter for non-LZMA compressors (#2459)
Mostyn Bramley-Moore [Sat, 28 Dec 2024 23:36:01 +0000 (00:36 +0100)] 
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.

7 months agoFix format strings (#2457)
Graham Percival [Sat, 28 Dec 2024 19:03:17 +0000 (11:03 -0800)] 
Fix format strings (#2457)

7 months agoAdd tar/test/test_list_item (#2454)
Graham Percival [Sat, 28 Dec 2024 19:01:19 +0000 (11:01 -0800)] 
Add tar/test/test_list_item (#2454)

7 months agoFix the test for NOABSOLUTEPATHS (#2456)
Tim Kientzle [Fri, 27 Dec 2024 23:51:33 +0000 (15:51 -0800)] 
Fix the test for NOABSOLUTEPATHS (#2456)

The test inadvertently tried to manipulate the wrong archive at one
point.

7 months agotar: fix bug when -s/a/b/ used more than once with b flag (#2435)
Stephane Chazelas [Fri, 27 Dec 2024 23:20:16 +0000 (23:20 +0000)] 
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>
7 months agoFix -Werror=warning error and wrap some INSTALL directives with an ENABLE_INSTALL...
Zeun [Fri, 27 Dec 2024 20:53:13 +0000 (09:53 +1300)] 
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

7 months agoci: use at most the number of make threads as there are cores on mac and linux github...
Mostyn Bramley-Moore [Fri, 27 Dec 2024 20:40:47 +0000 (21:40 +0100)] 
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.

7 months agoFix remaining TODOs in test_stdio.c (#2444)
Graham Percival [Fri, 27 Dec 2024 20:38:03 +0000 (12:38 -0800)] 
Fix remaining TODOs in test_stdio.c (#2444)

7 months agoRemove unnecessary semicolons (#2450)
Graham Percival [Wed, 25 Dec 2024 17:35:54 +0000 (09:35 -0800)] 
Remove unnecessary semicolons (#2450)

7 months agoRemove unreachable 'break' statements (#2451)
Graham Percival [Wed, 25 Dec 2024 17:33:11 +0000 (09:33 -0800)] 
Remove unreachable 'break' statements (#2451)

7 months agoFix %d -> %u for unsigned int from i4le() (#2448)
Graham Percival [Tue, 24 Dec 2024 23:27:26 +0000 (15:27 -0800)] 
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.)

7 months agoFix CRLF line endings in source files (#2449)
Graham Percival [Tue, 24 Dec 2024 23:25:53 +0000 (15:25 -0800)] 
Fix CRLF line endings in source files (#2449)

7 months agoReject relative path for test refdir (#2445)
Graham Percival [Tue, 24 Dec 2024 19:51:50 +0000 (11:51 -0800)] 
Reject relative path for test refdir (#2445)

7 months agoFix a few clang nitpicks (#2447)
Graham Percival [Tue, 24 Dec 2024 19:50:19 +0000 (11:50 -0800)] 
Fix a few clang nitpicks (#2447)

Fixes warnings found by:
```
-Wformat-non-iso
-Wnewline-eof
-Wmissing-variable-declarations
```

7 months agoFix some TODOs in tar/test/test_stdio.c (#2442)
Graham Percival [Thu, 19 Dec 2024 22:24:57 +0000 (14:24 -0800)] 
Fix some TODOs in tar/test/test_stdio.c (#2442)

7 months agoRemove liblzmadec remnants (#2436)
Mostyn Bramley-Moore [Sun, 15 Dec 2024 22:14:57 +0000 (23:14 +0100)] 
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.

7 months ago7zip reader: add LZMA + RISCV BCJ filter (#2403)
Mostyn Bramley-Moore [Sun, 15 Dec 2024 22:12:02 +0000 (23:12 +0100)] 
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.

7 months ago7zip writer: support multithreaded zstandard compression (#2391)
Mostyn Bramley-Moore [Sun, 15 Dec 2024 22:10:17 +0000 (23:10 +0100)] 
7zip writer: support multithreaded zstandard compression (#2391)

Command example:
bsdtar -cavf /tmp/foo.7z --options='compression=zstd,threads=4' *

7 months agoRemove unnecessary HAVE_LZMA_FILTER_ARM64 feature check (#2433)
Mostyn Bramley-Moore [Wed, 11 Dec 2024 04:35:16 +0000 (05:35 +0100)] 
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

7 months agoHandle truncation in the middle of a GNU long linkname (#2422)
Tim Kientzle [Tue, 10 Dec 2024 05:09:29 +0000 (21:09 -0800)] 
Handle truncation in the middle of a GNU long linkname (#2422)

Thanks to gbdngb12 김동건 for reporting this.

Resolves Issue #2415

7 months agoci: make skipped tests more obvious (#2430)
Mostyn Bramley-Moore [Mon, 9 Dec 2024 02:08:34 +0000 (03:08 +0100)] 
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
```

7 months agoReport skipped tests to cmake/ctest (#2429)
Mostyn Bramley-Moore [Mon, 9 Dec 2024 02:07:49 +0000 (03:07 +0100)] 
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.

7 months agoci: speed up windows/mingw build by using multiple make jobs (#2428)
Mostyn Bramley-Moore [Sun, 8 Dec 2024 00:39:46 +0000 (01:39 +0100)] 
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.

7 months agoci: make autoconf look for headers and libraries in /opt/homebrew if those directorie...
Mostyn Bramley-Moore [Sat, 7 Dec 2024 23:11:19 +0000 (00:11 +0100)] 
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.

7 months agoci: log bsdtar's version text, so we can see which support libraries were used (...
Mostyn Bramley-Moore [Sat, 7 Dec 2024 23:10:42 +0000 (00:10 +0100)] 
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.

7 months agoci: find liblzma >= 5.6.3 on windows msvc tests (#2421)
Mostyn Bramley-Moore [Sat, 7 Dec 2024 03:56:06 +0000 (04:56 +0100)] 
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.

7 months agoSpelling fixes (#2412)
Graham Percival [Fri, 6 Dec 2024 16:00:03 +0000 (08:00 -0800)] 
Spelling fixes (#2412)

7 months agoCheck for tcgetattr / tcsetattr before using it for readpassphrase implementation...
Julian Uy [Fri, 6 Dec 2024 15:58:58 +0000 (09:58 -0600)] 
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

7 months agoAdd missing definition for getline polyfill (#2425)
Julian Uy [Fri, 6 Dec 2024 15:57:27 +0000 (09:57 -0600)] 
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.

7 months agobsdtar.1: Mention rar support + manual page polish (#2423)
Alexander Ziaee [Fri, 6 Dec 2024 15:50:06 +0000 (10:50 -0500)] 
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.

7 months agoTest with XZ Utils 5.6.3 on windows CI jobs (#2417)
Mostyn Bramley-Moore [Sun, 1 Dec 2024 23:29:46 +0000 (00:29 +0100)] 
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.

7 months agonit(tar): fix typo (#2420)
MithicSpirit [Sun, 1 Dec 2024 03:21:45 +0000 (22:21 -0500)] 
nit(tar): fix typo (#2420)

8 months agoMoving the tests' integer reading functions to test_utils. (#2410)
ljdarj [Sun, 17 Nov 2024 01:42:27 +0000 (02:42 +0100)] 
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.

8 months agoIgnore ustar size when pax size is present (#2405)
Tim Kientzle [Wed, 6 Nov 2024 21:21:54 +0000 (13:21 -0800)] 
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

9 months ago7zip reader: add SPARC filter support for non-LZMA compressors (#2399)
Mostyn Bramley-Moore [Tue, 29 Oct 2024 02:29:23 +0000 (03:29 +0100)] 
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.

9 months agoRevert "Use proper Create OS value on Windows to fix archive charset detection (...
Tim Kientzle [Mon, 28 Oct 2024 02:34:51 +0000 (19:34 -0700)] 
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.

9 months agoRename bsdtar test_extract_tar_absolute_paths source file for consistency (#2400)
Mostyn Bramley-Moore [Sun, 27 Oct 2024 15:43:59 +0000 (16:43 +0100)] 
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.

9 months agotests: redirect stdout in one call in test_extract_tar_absolute_paths (#2386) 2394/head
Martin Matuška [Fri, 25 Oct 2024 17:45:28 +0000 (19:45 +0200)] 
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.

9 months agoFix tests added in #2284 (#2387)
Martin Matuska [Wed, 23 Oct 2024 16:47:32 +0000 (18:47 +0200)] 
Fix tests added in #2284 (#2387)

9 months agoRevert "add `--mac-metadata` test for `--format zip` - see #2041 (#2045)"
Martin Matuska [Wed, 23 Oct 2024 16:45:23 +0000 (18:45 +0200)] 
Revert "add `--mac-metadata` test for `--format zip` - see #2041 (#2045)"

This reverts commit ea56096020e2c6c764052adfab63e11fd745f9de.

9 months agoadd `--mac-metadata` test for `--format zip` - see #2041 (#2045)
nielash [Tue, 22 Oct 2024 09:16:55 +0000 (05:16 -0400)] 
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!

9 months agowrite_xar: move libxml2 behind an abstraction layer (#1849)
Dustin L. Howett [Tue, 22 Oct 2024 09:10:50 +0000 (04:10 -0500)] 
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.

9 months ago7zip writer: initial support for zstandard compression (#2137)
Mostyn Bramley-Moore [Tue, 22 Oct 2024 09:01:55 +0000 (11:01 +0200)] 
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

9 months agoAdding XZ, LZMA, ZSTD and BZIP2 support to ZIP writer (#2284)
ljdarj [Tue, 22 Oct 2024 08:58:22 +0000 (10:58 +0200)] 
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.

9 months agoUse proper Create OS value on Windows to fix archive charset detection (#2240)
unxed [Tue, 22 Oct 2024 08:56:19 +0000 (10:56 +0200)] 
Use proper Create OS value on Windows to fix archive charset detection (#2240)

See https://sourceforge.net/p/sevenzip/bugs/2463

9 months agoReintroduce size_t cast to clarify the use of a u32 shift on a u64 arg (#2383)
Dustin L. Howett [Tue, 22 Oct 2024 08:52:19 +0000 (03:52 -0500)] 
Reintroduce size_t cast to clarify the use of a u32 shift on a u64 arg (#2383)

Regressed in #2285

9 months agoVarious small fixes for Cygwin, Haiku, OpenIndiana (#2346)
vcoxvco [Mon, 14 Oct 2024 15:44:17 +0000 (17:44 +0200)] 
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>
9 months agotests: use const char instead of char in one case (#2381)
Martin Matuška [Sun, 13 Oct 2024 20:41:06 +0000 (22:41 +0200)] 
tests: use const char instead of char in one case (#2381)

Found in test_extract_cpio_absolute_paths.c when compiling FreeBSD base

9 months agoIgnore checksum mismatches when fuzzing tar archives (#2378)
Tim Kientzle [Sun, 13 Oct 2024 07:42:38 +0000 (00:42 -0700)] 
Ignore checksum mismatches when fuzzing tar archives (#2378)

This should speed up fuzzing just a bit, so we
can find more bugs!

9 months agoCI: Bump the all-actions group across 1 directory with 4 updates (#2379)
dependabot[bot] [Sun, 13 Oct 2024 07:42:01 +0000 (09:42 +0200)] 
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>
9 months agoIncrease the hole size for this test to 32MiB (#2380)
Tim Kientzle [Sun, 13 Oct 2024 07:35:17 +0000 (00:35 -0700)] 
Increase the hole size for this test to 32MiB (#2380)

APFS on macOS 15 seems to have a higher threshold for creating sparse
files.

9 months agoConvert the tools and respective tests to SPDX (#2317)
Emil Velikov [Sun, 13 Oct 2024 03:54:16 +0000 (04:54 +0100)] 
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>
9 months agoUpdate archive_private to avoid template keyword (#2342)
Christian Schmitz [Sun, 13 Oct 2024 00:47:30 +0000 (02:47 +0200)] 
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`

9 months agoconfigure.ac,CMakeLists.txt: Add libbsd on Haiku for readpassphrase (#2352)
vcoxvco [Sun, 13 Oct 2024 00:44:32 +0000 (02:44 +0200)] 
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>
9 months agoCI: Update build environments (#2373)
Martin Matuška [Sat, 12 Oct 2024 16:31:20 +0000 (18:31 +0200)] 
CI: Update build environments (#2373)

FreeBSD 13.3 -> 13.4
FreeBSD 14.0 -> 14.1
Ubuntu 22.04 -> 24.04

9 months agoFix two leaks in tar header parsing (#2377)
Tim Kientzle [Sat, 12 Oct 2024 11:54:23 +0000 (04:54 -0700)] 
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

9 months agotests: change file format from dos to unix in one test file (#2376)
Martin Matuška [Sat, 12 Oct 2024 03:54:59 +0000 (05:54 +0200)] 
tests: change file format from dos to unix in one test file (#2376)

9 months ago[7zip] Read/write symlink paths as UTF-8 (#2252)
Duncan Horn [Fri, 11 Oct 2024 06:30:25 +0000 (23:30 -0700)] 
[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: