0
0
mirror of https://github.com/libarchive/libarchive.git synced 2026-01-18 17:11:25 +01:00

7023 Commits

Author SHA1 Message Date
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:		27588eba50 ("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:		a335429c5e ("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