]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
2 years agoDon't call GetOEMCP() in Universal Windows Platform builds
Steve Lhomme [Wed, 24 May 2023 13:23:14 +0000 (15:23 +0200)] 
Don't call GetOEMCP() in Universal Windows Platform builds

It's not available [1] [2]. However we can use the intermediate CP_OEMCP
value. It can be used to compare charsets in create_sconv_object().
It won't work with comparing charsets in archive_string_default_conversion_for_read()
and archive_string_default_conversion_for_write(). current_codepage being
an actual CodePage value.

[1] https://learn.microsoft.com/en-us/uwp/win32-and-com/win32-apis#apis-from-api-ms-win-core-localization-l1-2-0dll
[2] https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getoemcp#requirements

2 years agoUse the common CMake BUILD_SHARED_LIBS to build shared library or not
Steve Lhomme [Thu, 25 May 2023 11:56:00 +0000 (13:56 +0200)] 
Use the common CMake BUILD_SHARED_LIBS to build shared library or not

https://cmake.org/cmake/help/v3.0/variable/BUILD_SHARED_LIBS.html

Usually it's built-in but make sure we have it on by default.

We don't need to rename the windows static library when it's the only one built.
This will also allow proper usage of the pkg-config file in this case. Otherwise
there is no way to select the static library that way.

2 years agoFix bcrypt detection on UNIX cross-compilation
Steve Lhomme [Thu, 25 May 2023 09:47:13 +0000 (11:47 +0200)] 
Fix bcrypt detection on UNIX cross-compilation

The Windows SDK uses an uppercase on the B, but mingw-w64 doesn't.
The autoconf detection already uses a lowercase bcrypt.

2 years agoFix build error when cross-compiling for Windows
Steve Lhomme [Thu, 25 May 2023 09:33:23 +0000 (11:33 +0200)] 
Fix build error when cross-compiling for Windows

CHECK_C_SOURCE_RUNS generates a build error when cross-compiling.

ZLIB_WINAPI is the only one tested. When the run test fails, it's tested again
with just a compilation.

2 years agofix the CreateHardLinkW signature to match the real function
Steve Lhomme [Thu, 25 May 2023 08:16:08 +0000 (10:16 +0200)] 
fix the CreateHardLinkW signature to match the real function

The `ret` variable was already using BOOL instead of BOOLEAN.

2 years agoDisable CreateSymbolicLinkW use in UWP builds
Steve Lhomme [Thu, 25 May 2023 07:38:30 +0000 (09:38 +0200)] 
Disable CreateSymbolicLinkW use in UWP builds

The call is forbidden:
https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createsymboliclinkw#requirements

2 years agoUse CreateHardLinkW and CreateSymbolicLinkW directly on Vista+ builds
Steve Lhomme [Thu, 25 May 2023 07:53:49 +0000 (09:53 +0200)] 
Use CreateHardLinkW and CreateSymbolicLinkW directly on Vista+ builds

No need to load the kernel library manually. It's always available. It's not
possible to load it in Universal Windows Platform (UWP) builds anyway.

No need to load the kernel library manually. It's always available. It's not
possible to load it in Universal Windows Platform (UWP) builds anyway.

2 years agoDisable program call with stdin/stdout usage on UWP builds
Steve Lhomme [Wed, 24 May 2023 13:14:33 +0000 (15:14 +0200)] 
Disable program call with stdin/stdout usage on UWP builds

Some calls are not allowed:
* WaitForInputIdle [1]
* SetHandleInformation [2]
* STARTF_XXX flags for CreateProcess are not allowed

[1] https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-waitforinputidle#requirements
[2] https://learn.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-sethandleinformation#requirements

2 years agofixup! someone messed up the list
Mingye Wang [Fri, 26 May 2023 14:12:27 +0000 (22:12 +0800)] 
fixup! someone messed up the list

2 years agoarchive_read_set_options.3: document zip options
Mingye Wang [Fri, 26 May 2023 14:07:01 +0000 (22:07 +0800)] 
archive_read_set_options.3: document zip options

2 years agoProperly guard calls to sigaction
uyjulian [Sat, 27 May 2023 06:36:55 +0000 (01:36 -0500)] 
Properly guard calls to sigaction

2 years agoFix certain unused variables on certain conditions
uyjulian [Sat, 27 May 2023 06:50:12 +0000 (01:50 -0500)] 
Fix certain unused variables on certain conditions

2 years agoProperly guard calls to lstat
uyjulian [Sat, 27 May 2023 06:44:51 +0000 (01:44 -0500)] 
Properly guard calls to lstat

2 years agoRename to avoid arc4random_buf static definition clashing
uyjulian [Sat, 27 May 2023 06:52:57 +0000 (01:52 -0500)] 
Rename to avoid arc4random_buf static definition clashing

2 years ago7zip reader: add 7z ARM filter support for copy/bzip2/deflate/zstd
Mostyn Bramley-Moore [Sun, 11 Jun 2023 16:52:40 +0000 (18:52 +0200)] 
7zip reader: add 7z ARM filter support for copy/bzip2/deflate/zstd

This makes the new test_read_format_7zip_zstd_arm test pass. I expect
that the other compression algorithms in this group should also work
now.

2 years ago7zip reader: add some 7z ARM filter tests
Mostyn Bramley-Moore [Sun, 11 Jun 2023 15:32:57 +0000 (17:32 +0200)] 
7zip reader: add some 7z ARM filter tests

Note that test_read_format_7zip_lzma2_arm passes, while
test_read_format_7zip_zstd_arm fails, I believe because
liblzma implements these filters internally for itself, unlike the
other compression libraries.

These two archives contain a linux C hello world executable, built for
gnueabihf. They were created like so (the first one using a fork of
7-zip with zstandard support):
7z a -t7z -m0=zstd -mf=ARM libarchive/test/test_read_format_7zip_zstd_arm.7z hw-gnueabihf
and
7z a -t7z -m0=lzma2 -mf=ARM libarchive/test/test_read_format_7zip_lzma2_arm.7z hw-gnueabihf

2 years ago7zip reader: add support for zstandard compression in 7z archives
Mostyn Bramley-Moore [Mon, 29 May 2023 10:01:47 +0000 (12:01 +0200)] 
7zip reader: add support for zstandard compression in 7z archives

Zstandard support is not yet available in 7-Zip, though it is planned
for a future release:
https://sourceforge.net/p/sevenzip/feature-requests/1580/

The compression ID used here (4F71101) is copied from a popular 7-Zip
fork, which added ZSTD support back in 2017, and is mentioned in the
upstream 7-Zip ticket linked above:
https://github.com/mcmilk/7-Zip-zstd.git

Note that this does not add write support for Zstandard compression
in 7z archives.

Relates to #1656.

2 years agoAdd some 7zip zstd reader tests
Mostyn Bramley-Moore [Mon, 29 May 2023 06:25:37 +0000 (08:25 +0200)] 
Add some 7zip zstd reader tests

There is a popular 7-Zip fork with zstandard support, with releases as
far back as 2017:
https://github.com/mcmilk/7-Zip-zstd.git

Zstandard support is not yet available in 7-Zip, though it is planned
for a future release:
https://sourceforge.net/p/sevenzip/feature-requests/1580/

This change adds a couple of tests for reading 7-Zip archives which
use zstandard compression. They are expected to fail until support is
added in the following commit.

Relates to #1656.

2 years agosetup_current_filesystem: fail if name_max is 0
Luke Mewburn [Sat, 10 Jun 2023 10:44:52 +0000 (11:44 +0100)] 
setup_current_filesystem: fail if name_max is 0

Add error handling to the USE_READDIR_R code paths that set name_max
from struct statfs or statvfs; if the determined name_max == 0
then return an error.

Avoids a crash in tree_dir_next_posix() when the calculation of
dirent_size from name_max is too small for the memory allocated
for struct dirent.

This may fix Github issue #1149
This may fix NetBSD PR https://gnats.netbsd.org/56080

2 years agoLinux: use statvfs for name_max if available
Luke Mewburn [Sat, 10 Jun 2023 10:21:17 +0000 (11:21 +0100)] 
Linux: use statvfs for name_max if available

If using HAVE_STATVFS, set name_max from svfs.f_namelen
instead of sfs.f_namelen, to be consistent with the
rest of the function.

Noticed by code inspection.

2 years agofix unused variable error if no zstd
Wei-Cheng Pan [Thu, 15 Jun 2023 15:34:58 +0000 (00:34 +0900)] 
fix unused variable error if no zstd

2 years agoPrefer OR over addition (#1915)
AtariDreams [Sun, 9 Jul 2023 16:24:17 +0000 (12:24 -0400)] 
Prefer OR over addition (#1915)

Also cast all being ORed to uint64_t when creating a uint64_t.

This makes the code more idiomatic to compilers.

2 years agoCI: update FreeBSD versions (#1907)
Ed Maste [Wed, 21 Jun 2023 02:48:43 +0000 (22:48 -0400)] 
CI: update FreeBSD versions (#1907)

Update to latest released versions (12.4 and 13.2)

2 years agoReduce overlinking per pkg-config spec (#1870)
Enji Cooper [Sat, 13 May 2023 04:12:01 +0000 (21:12 -0700)] 
Reduce overlinking per pkg-config spec (#1870)

libssl isn't required for libarchive. Remove libssl so the installed .pc
file doesn't cause consumers to subsequently overlink libssl into their
code.

This doesn't affect how the code is linked -- only consumers of the
pkg-config specified spec.

2 years agoFix FreeBSD builds with WARNS=6 (#1869)
Enji Cooper [Sat, 13 May 2023 04:11:07 +0000 (21:11 -0700)] 
Fix FreeBSD builds with WARNS=6 (#1869)

WARNS=6 on FreeBSD passes several CFLAGS that causes the previous code
to fail with `-Wincompatible-pointer-types-discards-qualifiers` when
compiled with clang.

This particular change adjusts the code to be
`-Wincompatible-pointer-types-discards-qualifiers` clean. This change
changes the calls to use OSSL_PARAM macro abbreviated calls, instead of
calling more verbose (and less documented) callers.

While here, also address a `mac` object leak if `ctx` cannot be
allocated cleanly by always free'ing `mac` after it's been attached to
`ctx`.

Co-authored-by: Pierre Pronchery <pierre@freebsdfoundation.org>
Sponsored by: The FreeBSD Foundation
Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>

2 years agoMake single bit bitfields unsigned to avoid clang 16 warning (#1860)
Dimitry Andric [Tue, 18 Apr 2023 00:59:32 +0000 (02:59 +0200)] 
Make single bit bitfields unsigned to avoid clang 16 warning (#1860)

Clang 16 introduced a warning about single bit bitfields in structs,
which is triggered by a few libarchive formats:

libarchive/archive_write_set_format_7zip.c:1541:13: error: implicit
truncation from 'int' to a one-bit wide bit-field changes value from 1
to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                    file->dir = 1;
                              ^ ~

This is because single bit bitfields only support values -1 and 0, if
they are signed.

For bitfields with two or more bits this can be intentional, but single
bit bitfields are typically used as booleans, so it is better to make
them unsigned.

2 years agofix typo in config.h.in (#1851)
Xin "Russell" Liu [Thu, 2 Mar 2023 05:29:50 +0000 (13:29 +0800)] 
fix typo in config.h.in (#1851)

2 years agoFix date (#1846)
Po-Chuan Hsieh [Sun, 19 Feb 2023 08:18:47 +0000 (16:18 +0800)] 
Fix date (#1846)

2 years agoarchive_read_data_into_fd: Increase pointer assignment check (#1843)
Li kunyu [Tue, 14 Feb 2023 04:34:35 +0000 (12:34 +0800)] 
archive_read_data_into_fd: Increase pointer assignment check (#1843)

2 years agoAllow tests to pass after 2038 (#1838)
Bernhard M. Wiedemann [Fri, 20 Jan 2023 05:07:45 +0000 (06:07 +0100)] 
Allow tests to pass after 2038 (#1838)

Now uses 33 bits (the maximum possible) in the ustar header in order
to support times out to 2106.

Fixes #1837

2 years agoFix cpio test in 2038 (#1836)
Bernhard M. Wiedemann [Fri, 13 Jan 2023 05:27:42 +0000 (06:27 +0100)] 
Fix cpio test in 2038 (#1836)

Without this patch, `bsdcpio_test_option_c` failed after 2038-01-19 with

```
 .../libarchive-3.6.2/cpio/test/test_option_c.c:143: Assertion failed: t >= now - 2
 .../libarchive-3.6.2/cpio/test/test_option_c.c:169: Assertion failed: t >= now - 2
 .../libarchive-3.6.2/cpio/test/test_option_c.c:205: Assertion failed: t >= now - 2
```

Background:
As part of my work on reproducible builds for openSUSE, I check that
software still gives identical build results in the future.
The usual offset is +16 years, because that is how long I expect some
software will be used in some places.
This showed up failing tests in our package build.
See https://reproducible-builds.org/ for why this matters.

2 years agoAdd tests for the new zstd options.
Dag-Erling Smørgrav [Tue, 20 Dec 2022 13:21:38 +0000 (14:21 +0100)] 
Add tests for the new zstd options.

2 years agoDocument the new zstd options.
Dag-Erling Smørgrav [Thu, 1 Dec 2022 17:43:31 +0000 (17:43 +0000)] 
Document the new zstd options.

2 years agoSupport producing multi-fragment zstd archives.
Dag-Erling Smørgrav [Tue, 22 Nov 2022 02:52:43 +0000 (02:52 +0000)] 
Support producing multi-fragment zstd archives.

When the `zstd:frame-per-file` option is specified, the zstd filter will start a new frame when flushed, i.e. for each file in the archive.

The `zstd:min-frame-size=N` option modifies the `zstd:frame-per-file` option in that it will not start a new frame unless the current one exceeds `N` bytes.

When the `zstd:max-frame-size=N` option is specified, the zstd filter will start a new frame any time the compressed size of the previous one exceeds `N` bytes.

These options decrease compression efficiency by a varying amount (depending on the exact composition of its contents) but render the tarball seekable, to a certain extent.

2 years agoFlush write filters between entries.
Dag-Erling Smørgrav [Mon, 14 Nov 2022 18:05:42 +0000 (19:05 +0100)] 
Flush write filters between entries.

* Add a flush() method to write filters.
* Add an __archive_write_filters_flush() function which iterates over filters in order and invokes the flush method for any filter that has one and that has written data.
* Call __archive_write_filters_flush() before writing a new header.

2 years agoClean up zstd support code.
Dag-Erling Smørgrav [Mon, 14 Nov 2022 18:03:14 +0000 (19:03 +0100)] 
Clean up zstd support code.

2 years agoDo not account for NULL terminator when comparing with "TRAILER!!!" (#1814)
Rose [Mon, 9 Jan 2023 14:19:30 +0000 (09:19 -0500)] 
Do not account for NULL terminator when comparing with "TRAILER!!!" (#1814)

Because at that point, you may as well replace the whole thing with
strcmp

2 years agoUpdate autotools and fix warnings (#1815)
Rose [Mon, 9 Jan 2023 14:18:30 +0000 (09:18 -0500)] 
Update autotools and fix warnings (#1815)

We do not need to check TIME_WITH_SYS_TIME anymore. We can check
HAVE_SYS_TIME_H and not bother checking for C99.

2 years agoreplace time64 functions with normal ones (#1830)
Rosen Penev [Mon, 9 Jan 2023 14:15:55 +0000 (06:15 -0800)] 
replace time64 functions with normal ones (#1830)

Otherwise there are 32/64-bit pointer conversions going on. In Windows
since MSVC2005, time_t has been 64-bit. MinGW needs a hack to get 64-bit
time_t.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2 years agofurther cleanup _localtime64_s (#1824)
Rosen Penev [Wed, 28 Dec 2022 22:05:16 +0000 (14:05 -0800)] 
further cleanup _localtime64_s (#1824)

These were missing from 2d329073435d36065ce30bfd29428f6a45e41016

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2 years agoOnly add "iconv" to the .pc file if needed (#1825)
Peter Pentchev [Wed, 28 Dec 2022 22:04:40 +0000 (00:04 +0200)] 
Only add "iconv" to the .pc file if needed (#1825)

Hi,

Thanks for writing and maintaining libarchive!

What do you think about this trivial change that does not add "iconv" to
the pkg-config file's list of required packages unless it is actually
needed? On at least Debian GNU/Linux systems, the iconv(3) function is
part of the system C library and there is no Debian package that
installs an iconv.pc file, so I had to make this change to the Debian
package of libarchive.

Thanks again, and keep up the great work!

G'luck,
Peter

2 years agoadd "no sanitize undefined" attribute with clang (#1827)
TERESH1 [Wed, 28 Dec 2022 22:03:20 +0000 (01:03 +0300)] 
add "no sanitize undefined" attribute with clang (#1827)

Issue #1826

2 years agoMemory leaks fix for tests (#1829)
TERESH1 [Wed, 28 Dec 2022 02:30:21 +0000 (05:30 +0300)] 
Memory leaks fix for tests (#1829)

Issue #1828

2 years agocleanup _localtime64_s (#1820)
Rosen Penev [Tue, 20 Dec 2022 12:48:42 +0000 (04:48 -0800)] 
cleanup _localtime64_s (#1820)

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2 years agoLibarchive 3.6.3dev
Martin Matuska [Fri, 9 Dec 2022 15:13:56 +0000 (16:13 +0100)] 
Libarchive 3.6.3dev

2 years agoRelease 3.6.2 v3.6.2
Martin Matuska [Wed, 7 Dec 2022 13:42:29 +0000 (14:42 +0100)] 
Release 3.6.2

2 years agoarchive_hmac: use EVP_MAC_*() in OpenSSL 3.0
Martin Matuska [Fri, 9 Dec 2022 13:23:14 +0000 (14:23 +0100)] 
archive_hmac: use EVP_MAC_*() in OpenSSL 3.0

HMAC_*() functions have been deprecated since OpenSSL 3.0

2 years agoCI: update Ubuntu to 22.04 and MacOS to 12
Martin Matuska [Fri, 9 Dec 2022 12:04:45 +0000 (13:04 +0100)] 
CI: update Ubuntu to 22.04 and MacOS to 12

2 years agoarchive_read_support_format_tar: avoid always-true comparsion
Martin Matuska [Thu, 8 Dec 2022 15:27:31 +0000 (16:27 +0100)] 
archive_read_support_format_tar: avoid always-true comparsion

Reported by: GitHub CodeQL
Code Scanning Alert: 125

2 years agotest_sparse_basic: avoid always-true comparsion
Martin Matuska [Thu, 8 Dec 2022 15:27:00 +0000 (16:27 +0100)] 
test_sparse_basic: avoid always-true comparsion

Reported by: CodeQL
Code Scanning Alert: 126

2 years agotest_main.c: omit always-true comparsion
Martin Matuska [Thu, 8 Dec 2022 15:26:37 +0000 (16:26 +0100)] 
test_main.c: omit always-true comparsion

Reported by: CodeQL
Code Scanning Alert: 127

2 years agotest_read_format_rar5: correctly use verify_data()
Martin Matuska [Thu, 8 Dec 2022 15:10:46 +0000 (16:10 +0100)] 
test_read_format_rar5: correctly use verify_data()

Reported by: CodeQL
Code Scanning Alert: 129

2 years agomtree reader: check __archive_rb_tree_find_node() for NULL return
Martin Matuska [Thu, 8 Dec 2022 15:06:39 +0000 (16:06 +0100)] 
mtree reader: check __archive_rb_tree_find_node() for NULL return

Reported by: GitHub CodeQL
Code Scanning Alert: 190

2 years agoarchive_read_disk_posix: fail if unable to alocate memory in tree_push()
Martin Matuska [Thu, 8 Dec 2022 15:05:53 +0000 (16:05 +0100)] 
archive_read_disk_posix: fail if unable to alocate memory in tree_push()

Reported by: GitHub CodeQL
Code Scanning Alert: 189

2 years agovarious: fix unitialized local variables
Martin Matuska [Thu, 8 Dec 2022 14:08:14 +0000 (15:08 +0100)] 
various: fix unitialized local variables

Reported by: GitHub CodeQL
Code scanning alerts: 214, 215, 216

2 years agotests: silence localtime() CodeQL warnings
Martin Matuska [Wed, 7 Dec 2022 23:20:58 +0000 (00:20 +0100)] 
tests: silence localtime() CodeQL warnings

Use localtime_r() or _localtime64_s() if available

2 years agotests: silence more CodeQL warnings in test_utils/test_main.c
Martin Matuska [Wed, 7 Dec 2022 23:04:54 +0000 (00:04 +0100)] 
tests: silence more CodeQL warnings in test_utils/test_main.c

Catch one more uncatched strcpy() and strcat()

2 years agotests: silence some CodeQL warnings in test_utils/test_main.c
Martin Matuska [Wed, 7 Dec 2022 15:02:48 +0000 (16:02 +0100)] 
tests: silence some CodeQL warnings in test_utils/test_main.c

Use fchmod() instead of chmod() if available
Use strncpy() and strncat() instead of strcpy() and strcat()

2 years agotests: silence CodeQL warning in tar/test_option_b
Martin Matuska [Wed, 7 Dec 2022 14:59:14 +0000 (15:59 +0100)] 
tests: silence CodeQL warning in tar/test_option_b

Use strncpy() and strncat() instead of strcpy() and strcat()

2 years agocab reader: cast to int when subtracting unsigned integers
Martin Matuska [Wed, 7 Dec 2022 14:52:54 +0000 (15:52 +0100)] 
cab reader: cast to int when subtracting unsigned integers

Found by: GitHub CodeQL

2 years agoAdd CodeQL workflow for GitHub code scanning (#1800)
lgtm-com[bot] [Wed, 7 Dec 2022 13:48:03 +0000 (14:48 +0100)] 
Add CodeQL workflow for GitHub code scanning (#1800)

Co-authored-by: LGTM Migrator <lgtm-migrator@users.noreply.github.com>
2 years agoMerge pull request #1806 from kikht/share-write
Martin Matuška [Wed, 7 Dec 2022 12:06:19 +0000 (13:06 +0100)] 
Merge pull request #1806 from kikht/share-write

Use FILE_SHARE_WRITE and FILE_SHARE_DELETE when opening files on Windows

2 years agoMerge pull request #1771 from EwgeniWolowik/extend_cleanup_pathname_by_windows_remote...
Martin Matuška [Tue, 6 Dec 2022 11:11:34 +0000 (12:11 +0100)] 
Merge pull request #1771 from EwgeniWolowik/extend_cleanup_pathname_by_windows_remote_path

 Fixed issue #1770: base dir deals with network drive paths like \\server\file

2 years agoMerge pull request #1802 from banjiuqingshan/master
Martin Matuška [Tue, 6 Dec 2022 11:11:03 +0000 (12:11 +0100)] 
Merge pull request #1802 from banjiuqingshan/master

free mstr to fix memory leaks

2 years agoMerge pull request #1772 from bgermann/master
Martin Matuška [Tue, 6 Dec 2022 11:10:48 +0000 (12:10 +0100)] 
Merge pull request #1772 from bgermann/master

archive_entry_pathname() tries UTF-8 if MBS returns EILSEQ

2 years agoMerge pull request #1793 from flyingdutchman23/fix-cmake-warning
Martin Matuška [Tue, 6 Dec 2022 08:58:24 +0000 (09:58 +0100)] 
Merge pull request #1793 from flyingdutchman23/fix-cmake-warning

Fix CMake warning

2 years agoMerge pull request #1805 from banjiuqingshan/sync-master
Martin Matuška [Tue, 6 Dec 2022 08:57:02 +0000 (09:57 +0100)] 
Merge pull request #1805 from banjiuqingshan/sync-master

use regfree to release the memory

2 years agoUse FILE_SHARE_WRITE and FILE_SHARE_DELETE when opening files on Windows 1806/head
Vladimir Kikhtenko [Fri, 18 Nov 2022 06:46:18 +0000 (12:46 +0600)] 
Use FILE_SHARE_WRITE and FILE_SHARE_DELETE when opening files on Windows

Many standard libraries(
[libc++](https://github.com/llvm/llvm-project/blob/main/libcxx/src/filesystem/posix_compat.h#L159),
[go](https://cs.opensource.google/go/go/+/refs/tags/go1.19.3:src/syscall/syscall_windows.go;l=331),
[rust](https://doc.rust-lang.org/src/std/os/windows/fs.rs.html#126-131)
) open files on windows with `FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE`
mode by default. Libarchive uses only `FILE_SHARE_READ`, so when file is
being opened by any program that uses these standard libraries
libarchive fails to open it. Here we change libarchive shared flags, so
it plays well with common practice in other programs.

2 years agouse regfree to release the memory 1805/head
banjiuqingshan [Fri, 18 Nov 2022 01:37:00 +0000 (09:37 +0800)] 
use regfree to release the memory

use regfree() to release the memory requested by the regular expression.#1804

2 years agofree mstr to fix memory leaks 1802/head
banjiuqingshan [Tue, 15 Nov 2022 02:35:08 +0000 (10:35 +0800)] 
free mstr to fix memory leaks

free mstr to fix memory leaks.#1801

2 years agoMerge pull request #1790 from jvoisin/extend_nocrcerr
Martin Matuška [Wed, 2 Nov 2022 08:55:23 +0000 (09:55 +0100)] 
Merge pull request #1790 from jvoisin/extend_nocrcerr

Extend the usage of the DONT_FAIL_ON_CRC_ERROR macro

2 years agoMerge pull request #1786 from Malterlib/oob-windows-symlinks
Martin Matuška [Wed, 2 Nov 2022 08:53:46 +0000 (09:53 +0100)] 
Merge pull request #1786 from Malterlib/oob-windows-symlinks

Fix Windows symlink checks can reads past end of string

2 years agoMerge pull request #1797 from neheb/a
Tim Kientzle [Wed, 2 Nov 2022 03:09:47 +0000 (20:09 -0700)] 
Merge pull request #1797 from neheb/a

cmake config ${} to @@

2 years agocmake config ${} to @@ 1797/head
Rosen Penev [Tue, 1 Nov 2022 22:45:38 +0000 (15:45 -0700)] 
cmake config ${} to @@

meson's cmake config file handling does not support mixing ${} and @@ in
the same file. Switch to @@ for consistency.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2 years agoFix CMake warning 1793/head
Joris Clement [Fri, 28 Oct 2022 15:22:47 +0000 (17:22 +0200)] 
Fix CMake warning

The warnings occurs at least with CMake version 3.24. It is caused by
CMake trying to find the gcc library due to case sensitivity.

The warning message was:
```
CMake Warning (dev) at /usr/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (LIBGCC)
  does not match the name of the calling package (LibGCC).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  build/cmake/FindLibGCC.cmake:17 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:1269 (FIND_PACKAGE)
This warning is for project developers.  Use -Wno-dev to suppress it.
```

2 years agoMerge pull request #1784 from vtorri/vtorri_win10_2
Martin Matuška [Wed, 19 Oct 2022 11:28:10 +0000 (13:28 +0200)] 
Merge pull request #1784 from vtorri/vtorri_win10_2

cmake: set WINDOWS_VERSION to WIN10 by default

2 years agoExtend the usage of the DONT_FAIL_ON_CRC_ERROR macro 1790/head
Julien Voisin [Thu, 13 Oct 2022 12:13:19 +0000 (14:13 +0200)] 
Extend the usage of the DONT_FAIL_ON_CRC_ERROR macro

DONT_FAIL_ON_CRC_ERROR is already used in the rar5 support code, so let's make
use of it in another places as well. This should tremendously help with
fuzzing.

2 years agoFix out of bounds read in Windows symlink support 1786/head
Erik Olofsson [Thu, 6 Oct 2022 11:13:20 +0000 (13:13 +0200)] 
Fix out of bounds read in Windows symlink support

2 years agoFix potential out-of-bounds reads
Erik Olofsson [Thu, 6 Oct 2022 11:12:56 +0000 (13:12 +0200)] 
Fix potential out-of-bounds reads

2 years agocmake: set WINDOWS_VERSION to WIN10 by default 1784/head
Vincent Torri [Sat, 1 Oct 2022 18:55:41 +0000 (20:55 +0200)] 
cmake: set WINDOWS_VERSION to WIN10 by default

2 years agoMerge pull request #1721 from wangkerong/master
Tim Kientzle [Sat, 1 Oct 2022 16:53:23 +0000 (09:53 -0700)] 
Merge pull request #1721 from wangkerong/master

libarchive:uninitialized value

2 years agoMerge pull request #1777 from vtorri/vtorri_win10_1
Tim Kientzle [Sat, 1 Oct 2022 16:46:21 +0000 (09:46 -0700)] 
Merge pull request #1777 from vtorri/vtorri_win10_1

cmake: update possible values of WINDOWS_VERSION to also support Windows 10

2 years agoMerge pull request #1783 from vangyzen/issue1782
Tim Kientzle [Sat, 1 Oct 2022 16:42:16 +0000 (09:42 -0700)] 
Merge pull request #1783 from vangyzen/issue1782

Support reading mtree files with tabs

2 years agoMerge pull request #1781 from neheb/pkgconfigh
Tim Kientzle [Sat, 1 Oct 2022 16:41:05 +0000 (09:41 -0700)] 
Merge pull request #1781 from neheb/pkgconfigh

cmake: use pkgconfig for zstd lookup

2 years agoSupport reading mtree files with tabs 1783/head
Eric van Gyzen [Fri, 30 Sep 2022 15:28:09 +0000 (10:28 -0500)] 
Support reading mtree files with tabs

Commit 45c5008c4 requires all characters in an mtree file to be
printable, as determined by `isprint()`.  This broke support for
reading mtree files with tab characters, which are valid and otherwise
supported by libarchive.  Allow them.  Add a unit test.

Fixes #1782

2 years agocmake: use pkgconfig for zstd lookup 1781/head
Rosen Penev [Fri, 30 Sep 2022 08:51:08 +0000 (01:51 -0700)] 
cmake: use pkgconfig for zstd lookup

As libzstd typically comes with a pkgconfig file, use it.

Fixes compilation at least on OpenWrt where host paths were leaking into
the build.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2 years agocmake: update possible values of WINDOWS_VERSION to also support Windows 10 1777/head
Vincent Torri [Tue, 20 Sep 2022 05:07:20 +0000 (07:07 +0200)] 
cmake: update possible values of WINDOWS_VERSION to also support Windows 10

2 years ago Fixed issue #1770: cleanup_pathname deals with network drive paths like \\server... 1771/head
Ewgeni Wolowik [Wed, 7 Sep 2022 09:02:23 +0000 (11:02 +0200)] 
 Fixed issue #1770: cleanup_pathname deals with network drive paths like \\server\file

2 years agoMerge pull request #1736 from uckelman-sf/mingw_fixes
Martin Matuška [Mon, 5 Sep 2022 12:56:09 +0000 (14:56 +0200)] 
Merge pull request #1736 from uckelman-sf/mingw_fixes

Fixes for running tests on Windows (or Wine)

2 years agoarchive_entry_pathname() tries UTF-8 if MBS returns EILSEQ 1772/head
John Reiser [Fri, 26 Aug 2022 16:51:19 +0000 (09:51 -0700)] 
archive_entry_pathname() tries UTF-8 if MBS returns EILSEQ

For better pathname portability across OS, in particular Windows to Linux.
Original bug: unrar in https://bugzilla.redhat.com/show_bug.cgi?id=2120926
        modified:   libarchive/archive_entry.c

3 years agoMerge pull request #1761 from kraj/master
Tim Kientzle [Fri, 5 Aug 2022 02:43:12 +0000 (19:43 -0700)] 
Merge pull request #1761 from kraj/master

libarchive: Remove unneeded linux/fs.h include

3 years agoMerge pull request #1745 from bobrofon/rar5-read_data_block
Tim Kientzle [Fri, 5 Aug 2022 02:30:29 +0000 (19:30 -0700)] 
Merge pull request #1745 from bobrofon/rar5-read_data_block

rar5: Fix random initial offset if using archive_read_data_into_fd

3 years agoMerge pull request #1751 from yugr/hide-symbols
Tim Kientzle [Sun, 31 Jul 2022 16:06:34 +0000 (09:06 -0700)] 
Merge pull request #1751 from yugr/hide-symbols

Hide internal symbols on platforms that support visibility annotations

3 years agoAdded missing file to CMakeLists. 1751/head
Yuri Gribov [Wed, 27 Jul 2022 18:30:57 +0000 (21:30 +0300)] 
Added missing file to CMakeLists.

3 years agoHide internal symbols on platforms that support visibility annotations (see discussio...
Yuri Gribov [Sun, 3 Jul 2022 07:54:39 +0000 (10:54 +0300)] 
Hide internal symbols on platforms that support visibility annotations (see discussion in gh-1017).

3 years agolibarchive: Do not include sys/mount.h when linux/fs.h is present 1761/head
Khem Raj [Mon, 25 Jul 2022 17:56:53 +0000 (10:56 -0700)] 
libarchive: Do not include sys/mount.h when linux/fs.h is present

These headers are in conflict and only one is needed by
archive_read_disk_posix.c therefore include linux/fs.h if it exists
otherwise include sys/mount.h

It also helps compiling with glibc 2.36
where sys/mount.h conflicts with linux/mount.h see [1]

[1] https://sourceware.org/glibc/wiki/Release/2.36

3 years agoMerge pull request #1753 from bungeman/check_size_attribute
Tim Kientzle [Mon, 25 Jul 2022 00:29:23 +0000 (17:29 -0700)] 
Merge pull request #1753 from bungeman/check_size_attribute

Validate entry_bytes_remaining in pax_attribute

3 years agoValidate entry_bytes_remaining in pax_attribute 1753/head
Ben Wagner [Tue, 19 Jul 2022 17:02:40 +0000 (13:02 -0400)] 
Validate entry_bytes_remaining in pax_attribute

The `size` attribute may contain a negative or too large value. Check
the range of the `entry_bytes_remaining` in `pax_attribute` the same way
as `header_common`. The test which is added passes both with and without
this change in a normal debug build. It is necessary to run with
`-fsanitize=undefined` to see that the undefined behavior is avoided.

Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=48467

3 years agoMerge pull request #1759 from obiwac/fix-1754
Tim Kientzle [Sun, 24 Jul 2022 06:50:07 +0000 (23:50 -0700)] 
Merge pull request #1759 from obiwac/fix-1754

libarchive: Handle a `calloc` returning NULL (fixes #1754)

3 years agolibarchive: Handle a `calloc` returning NULL (fixes #1754) 1759/head
obiwac [Fri, 22 Jul 2022 20:41:10 +0000 (22:41 +0200)] 
libarchive: Handle a `calloc` returning NULL (fixes #1754)