28 Commits
Author SHA1 Message Date
Brad King 995d842e98 Merge topic 'test-archive-symlink-win'
4229667859 Tests: Extend symlink-related archive tests to cross-platform
19f8fcfd24 Tests/File_Archive: Relax more stderr line matching

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !11941
2026-04-23 09:06:36 -04:00
Tyler Yankee 4229667859 Tests: Extend symlink-related archive tests to cross-platform
Use `cmake -E create_symlink` or `file(CREATE_LINK)` as appropriate
instead of `ln -sf` on UNIX only to extend cases of (a) symlinks inside
archives and (b) archive extraction to a directory symlink to non-UNIX
platforms where either of these modes may be supported.

The latter relies on the NEW behavior of CMP0205 as it uses
`COPY_ON_ERROR` for platforms where directory symlinks aren't
supported.

Issue: #27756
2026-04-22 13:59:20 -04:00
Brad King 35f7629b6e Merge topic 'revert-extract-symlink'
4397f89c16 Restore archive extraction between directory symlinks
6e638ce109 Tests/File_Archive: Relax stderr line matching

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !11931
2026-04-15 11:48:03 -04:00
Tyler Yankee 4397f89c16 Restore archive extraction between directory symlinks
Commit 03f19aa4ea (cmSystemTools: Fix path traversal vulnerability in
archive extraction, 2026-01-06, v4.3.0-rc1~179^2) incidentally
introduced the `ARCHIVE_EXTRACT_SECURE_SYMLINKS` flag when extracting
archives, which prevents extraction of objects whose location would be
altered by a symlink on disk. However, this particular behavior change
was never documented or tested alongside the other changes in the
commit (absolute paths and path traversal components).

Divergent behavior of this flag from `libarchive` on Windows and
non-Windows platforms needs further investigation. In particular, on
Windows, archives cannot be extracted through directory symlinks, but
can be extracted through junctions. On Linux, archives *can* still be
extracted through symlinks, and archives containing symlinks can be
extracted as well.

The symlink change breaks compatibility with many common use cases of
existing projects, e.g., when extracting an archive inside a symlinked
build directory. Revert the flag until this issue can be explored in a
future version of CMake.

Fixes: #27752
Reported-by: scivision <scivision@users.noreply.github.com>
2026-04-14 15:57:13 -04:00
Alex Overchenko 21eb53e9eb tar: Add option to specify the encoding of archive pathnames
Use OEM by default for backward compatibility

Fixes: #26903
2026-03-11 08:44:44 +03:00
Brad King 95040f37ed Tests/RunCMake/CommandLineTar: Improve formatting of error messages 2026-03-11 01:00:28 -04:00
Leslie P. Polzer 03f19aa4ea cmSystemTools: Fix path traversal vulnerability in archive extraction
Add security flags to libarchive extraction to prevent path traversal
(Zip Slip) and absolute path attacks:

- ARCHIVE_EXTRACT_SECURE_NODOTDOT: Block ".." path components
- ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS: Block absolute paths
- ARCHIVE_EXTRACT_SECURE_SYMLINKS: Block symlinks escaping extract dir

This hardens both `cmake -E tar` and `file(ARCHIVE_EXTRACT)` against
malicious archives that attempt to write files outside the intended
extraction directory.
2026-01-16 08:54:07 -05:00
Brad King 6015ef807d cmake -E tar: Improve error message formatting
Do not print file paths with our prose line wrapping, which breaks
on spaces.
2026-01-16 08:53:28 -05:00
AJIOB e4e29aeb66 cli tar: extend supported compression methods 2026-01-06 09:49:57 +03:00
AJIOB 94ae247d44 cli tar: support different algorithms for zip & 7z
Fixes: #27443
2025-12-11 12:00:31 -05:00
AJIOB d4d2a6a19d cli tar: support compression level
Fixes #27422
2025-12-05 20:00:24 +03:00
Brad King 9149ac3f37 Merge topic 'fix-27420'
4fdfa0db1a file(ARCHIVE_CREATE): support multithreading compression
cbf71b21b2 cli tar: support multithreading compression

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11460
2025-12-05 09:04:58 -05:00
AJIOB cbf71b21b2 cli tar: support multithreading compression
Fixes: #27420
2025-12-03 02:45:30 -05:00
AJIOB 5b87a5d53e cli tar: implement LZMA support
Fixes: #27433
2025-12-02 10:44:49 +03:00
Brad King 5c1ec64d20 Merge branch 'test-libarchive-3.8.2' into update-libarchive 2025-11-10 15:11:31 -05:00
Brad King 576117b7eb Tests: Update expected Zstandard magic number for libarchive 3.8.2
libarchive 3.8.2 enabled Zstandard's checksum feature in the zstd write
filter.  Update our tests' expected results accordingly.

Fixes: #27355
Reported-by: Funda Wang <fundawang@yeah.net>
2025-11-10 15:11:10 -05:00
AJIOB 5de7a09e77 Tests/RunCMake: Match dots more precisely, part 3 2025-10-20 14:45:24 -04:00
Brad King f4aa34daa7 Tests/RunCMake: Update cmake_minimum_required versions to 3.10
For policy-specific tests, use the version before the policy was
introduced.  Otherwise, use 3.10 where possible.
2024-10-03 11:52:22 -04:00
Brad King 1edf138506 Tests/RunCMake: Update cmake_minimum_required versions
For policy-specific tests, use the version before the policy was
introduced.  Otherwise, use 3.5 where possible.

Also, remove `cmake_minimum_required()` and `project()` calls from
individual cases where they are handled by `CMakeLists.txt`.
2023-02-11 06:24:22 -05:00
Kasper Laudrup 0b7fd783f8 cmake -E tar: Add --touch option
Similar to GNU tar add a --touch option to the tar extract command to
skip extracting the timestamps from the files in the archive
effectively touching them as if they were just created.

Issue: #22746
2022-03-23 14:41:34 +01:00
Kasper Laudrup f692cba34b Tests: Add test for 'cmake -E tar --mtime' option
Add a test for ensuring the `--mtime` option works as expected.
2022-03-23 14:41:34 +01:00
Brad King 05af1770a0 Merge topic 'tar-zstd-compression'
53cb1f2d04 cmake: Teach cmake -E tar command, Zstandard compression

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3357
2019-05-30 09:39:35 -04:00
Bartosz Kosiorek c8e217e0a7 cmake: tar: Allow selective extracting and listing of archives 2019-05-23 10:08:22 -04:00
Bartosz Kosiorek 53cb1f2d04 cmake: Teach cmake -E tar command, Zstandard compression
Fixes #18657
2019-05-22 03:46:55 +02:00
Bartosz Kosiorek ea9a2c1759 cmake: tar: Parse 'cmake -E tar' arguments 2019-03-20 09:28:49 -04:00
Bartosz Kosiorek 8634576dcb cmake: Don't interrupt archive creation if unable to read a file.
Rationale:
Currently during creation of archive by 'tar',
if error appears, it interrupt archive creation.
As a result only part of files are archived

This behaviour is not consistent with 'copy_directory', native 'tar'
and other command behaviour.
With this Merge Request this behaviour is fixed.
2019-03-18 17:55:35 +01:00
Bartosz Kosiorek 7c47fd8cd1 cmake: tar: Display warning when no files provided during archive creation 2019-03-18 17:08:20 +01:00
Nils Gladitz 6c4781baa9 Tests: Consolidate, refactor and extend -E tar tests 2015-04-10 08:32:32 -04:00