From 63888ed0f61e0d0839eb5383da7a6c2c44308203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20R=C3=B6hling?= Date: Fri, 22 Nov 2024 23:57:14 +0100 Subject: [PATCH] New upstream version 3.31.1 --- Help/command/add_custom_command.rst | 3 +- Help/generator/Visual Studio 10 2010.rst | 7 +- Help/generator/Visual Studio 11 2012.rst | 5 +- Help/generator/Visual Studio 12 2013.rst | 5 +- Help/generator/Visual Studio 9 2008.rst | 8 +- Help/manual/cmake-developer.7.rst | 4 +- Help/policy/CMP0132.rst | 2 + Help/policy/CMP0175.rst | 4 +- Help/release/3.29.rst | 4 +- Help/release/3.30.rst | 7 + Help/release/3.31.rst | 12 + Modules/FindBoost.cmake | 4 +- Modules/FindImageMagick.cmake | 4 +- Modules/FindSQLite3.cmake | 4 +- Modules/GoogleTestAddTests.cmake | 70 +++--- .../Internal/CMakeASMLinkerInformation.cmake | 2 +- .../Internal/CMakeCLinkerInformation.cmake | 2 +- .../Internal/CMakeCUDALinkerInformation.cmake | 2 +- .../Internal/CMakeCXXLinkerInformation.cmake | 2 +- .../CMakeFortranLinkerInformation.cmake | 2 +- .../Internal/CMakeHIPLinkerInformation.cmake | 2 +- .../Internal/CMakeOBJCLinkerInformation.cmake | 2 +- .../CMakeOBJCXXLinkerInformation.cmake | 2 +- .../CMakeSwiftLinkerInformation.cmake | 2 +- Modules/Platform/Linker/AIX-AIX.cmake | 1 + Modules/Platform/Linker/Android-ASM.cmake | 5 + Modules/Platform/Linker/Android-C.cmake | 5 + Modules/Platform/Linker/Android-CXX.cmake | 5 + Modules/Platform/Linker/Android-GNU-ASM.cmake | 4 + Modules/Platform/Linker/Android-GNU-C.cmake | 4 + Modules/Platform/Linker/Android-GNU-CXX.cmake | 4 + Modules/Platform/Linker/Android-LLD-ASM.cmake | 4 + Modules/Platform/Linker/Android-LLD-C.cmake | 4 + Modules/Platform/Linker/Android-LLD-CXX.cmake | 4 + .../Platform/Linker/Apple-AppleClang.cmake | 1 + Modules/Platform/Linker/Apple-LLD-C.cmake | 2 + Modules/Platform/Linker/Apple-LLD-CXX.cmake | 2 + Modules/Platform/Linker/Apple-LLD-OBJC.cmake | 2 + .../Platform/Linker/Apple-LLD-OBJCXX.cmake | 2 + Modules/Platform/Linker/Apple-MOLD-C.cmake | 2 + Modules/Platform/Linker/Apple-MOLD-CXX.cmake | 2 + Modules/Platform/Linker/Apple-MOLD-OBJC.cmake | 2 + .../Platform/Linker/Apple-MOLD-OBJCXX.cmake | 2 + Modules/Platform/Linker/CYGWIN-GNU.cmake | 1 + Modules/Platform/Linker/CYGWIN-LLD.cmake | 1 + Modules/Platform/Linker/FreeBSD-GNU.cmake | 1 + Modules/Platform/Linker/FreeBSD-LLD.cmake | 1 + Modules/Platform/Linker/GNU-GNU.cmake | 1 + Modules/Platform/Linker/Linux-GNU.cmake | 1 + .../Platform/Linker/Linux-GNUgold-ASM.cmake | 2 + Modules/Platform/Linker/Linux-GNUgold-C.cmake | 2 + .../Platform/Linker/Linux-GNUgold-CUDA.cmake | 2 + .../Platform/Linker/Linux-GNUgold-CXX.cmake | 2 + .../Linker/Linux-GNUgold-Fortran.cmake | 2 + .../Platform/Linker/Linux-GNUgold-HIP.cmake | 2 + Modules/Platform/Linker/Linux-LLD.cmake | 1 + Modules/Platform/Linker/Linux-MOLD.cmake | 2 + Modules/Platform/Linker/NetBSD-GNU.cmake | 1 + Modules/Platform/Linker/OpenBSD-GNU.cmake | 1 + Modules/Platform/Linker/OpenBSD-LLD.cmake | 1 + Modules/Platform/Linker/SerenityOS-GNU.cmake | 1 + Modules/Platform/Linker/SerenityOS-LLD.cmake | 1 + Modules/Platform/Linker/SunOS-GNU.cmake | 1 + Modules/Platform/Linker/SunOS-Solaris.cmake | 1 + Modules/Platform/Linker/Windows-GNU.cmake | 1 + Modules/Platform/Linker/Windows-LLD.cmake | 1 + Modules/Platform/Linker/Windows-MSVC.cmake | 1 + Modules/Platform/Linker/WindowsCE-C.cmake | 5 + Modules/Platform/Linker/WindowsCE-CXX.cmake | 5 + .../Platform/Linker/WindowsCE-MSVC-C.cmake | 4 + .../Platform/Linker/WindowsCE-MSVC-CXX.cmake | 4 + .../Linker/WindowsKernelModeDriver-C.cmake | 5 + .../Linker/WindowsKernelModeDriver-CXX.cmake | 5 + .../WindowsKernelModeDriver-MSVC-C.cmake | 4 + .../WindowsKernelModeDriver-MSVC-CXX.cmake | 4 + .../Platform/Linker/WindowsPhone-ASM.cmake | 15 ++ Modules/Platform/Linker/WindowsPhone-C.cmake | 15 ++ .../Platform/Linker/WindowsPhone-CXX.cmake | 15 ++ .../Linker/WindowsPhone-GNU-ASM.cmake | 4 + .../Platform/Linker/WindowsPhone-GNU-C.cmake | 4 + .../Linker/WindowsPhone-GNU-CXX.cmake | 4 + .../Linker/WindowsPhone-LLD-ASM.cmake | 4 + .../Platform/Linker/WindowsPhone-LLD-C.cmake | 4 + .../Linker/WindowsPhone-LLD-CXX.cmake | 4 + .../Linker/WindowsPhone-MSVC-ASM.cmake | 4 + .../Platform/Linker/WindowsPhone-MSVC-C.cmake | 4 + .../Linker/WindowsPhone-MSVC-CXX.cmake | 4 + .../Platform/Linker/WindowsStore-ASM.cmake | 15 ++ Modules/Platform/Linker/WindowsStore-C.cmake | 15 ++ .../Platform/Linker/WindowsStore-CXX.cmake | 15 ++ .../Linker/WindowsStore-GNU-ASM.cmake | 4 + .../Platform/Linker/WindowsStore-GNU-C.cmake | 4 + .../Linker/WindowsStore-GNU-CXX.cmake | 4 + .../Linker/WindowsStore-LLD-ASM.cmake | 4 + .../Platform/Linker/WindowsStore-LLD-C.cmake | 4 + .../Linker/WindowsStore-LLD-CXX.cmake | 4 + .../Linker/WindowsStore-MSVC-ASM.cmake | 4 + .../Platform/Linker/WindowsStore-MSVC-C.cmake | 4 + .../Linker/WindowsStore-MSVC-CXX.cmake | 4 + Modules/Platform/Linux-Initialize.cmake | 2 +- Source/CMakeVersion.cmake | 4 +- Source/cmAddCustomCommandCommand.cxx | 1 + Source/cmComputeLinkDepends.cxx | 9 + Source/cmExecuteProcessCommand.cxx | 26 ++- Source/cmExperimental.cxx | 4 +- Source/cmPolicies.cxx | 6 +- .../File_Generate/CMP0070-OLD-stderr.txt | 5 +- .../File_Generate/CMP0070-WARN-stderr.txt | 5 +- .../SourceProperty-CMP0070-OLD-stderr.txt | 5 +- .../GenEx-TARGET_PROPERTY/LOCATION-stderr.txt | 5 +- ...st-discovery-flush-script-check-list.cmake | 5 - ...discovery-flush-script-check-list.cmake.in | 34 +++ .../GoogleTestDiscoveryFlushScript.cmake | 8 +- .../RunCMake/GoogleTest/flush_script_test.cpp | 9 +- .../BinInInstallPrefix-CMP0052-OLD-stderr.txt | 5 +- .../SrcInInstallPrefix-CMP0052-OLD-stderr.txt | 5 +- .../CMP0028-OLD-iface-stderr.txt | 5 +- .../LinkItemValidation/CMP0028-OLD-stderr.txt | 5 +- .../LinkLibrariesStrategy/Inspect.cmake | 2 + .../LinkLibrariesStrategy/RunCMakeTest.cmake | 11 +- .../RunCMake/Ninja/CMP0058-OLD-by-stderr.txt | 5 +- .../RunCMake/Ninja/CMP0058-OLD-no-stderr.txt | 5 +- .../RunCMake/Ninja/CMP0058-WARN-by-stderr.txt | 5 +- .../RunCMake/Ninja/CMP0058-WARN-no-stderr.txt | 5 +- .../ExperimentalWarning-stderr.txt | 4 +- Tests/RunCMake/RunCMake.cmake | 5 +- .../VisibilityPreset/CMP0063-OLD-stderr.txt | 5 +- .../CMP0063-WARN-exe-stderr.txt | 5 +- .../CMP0063-WARN-no-stderr.txt | 5 +- .../CMP0063-WARN-obj-stderr.txt | 5 +- .../CMP0063-WARN-sta-stderr.txt | 5 +- .../add_custom_command/CMP0175-NEW-stderr.txt | 2 +- .../CMP0175-WARN-stderr.txt | 2 +- .../RunCMake/add_custom_command/CMP0175.cmake | 5 +- .../Before3_10-stderr.txt | 15 +- .../CompatBefore24-stderr.txt | 5 +- .../BuildFailure-CMP0061-OLD-stderr.txt | 5 +- .../RunCMake/include/CMP0024-WARN-stderr.txt | 5 +- Tests/RunCMake/install/CMP0062-OLD-stderr.txt | 5 +- .../RunCMake/list/GET-CMP0007-WARN-stderr.txt | 5 +- Tests/RunCMake/project/CMP0048-NEW-stderr.txt | 5 +- Tests/RunCMake/project/CMP0048-OLD-stderr.txt | 5 +- .../project_injected/CMP0048-WARN-stderr.txt | 5 +- Tests/RunCMake/try_compile/CMP0066-stderr.txt | 5 +- Utilities/Scripts/update-libarchive.bash | 2 +- Utilities/cmlibarchive/CMakeLists.txt | 8 + Utilities/cmlibarchive/build/version | 2 +- Utilities/cmlibarchive/libarchive/archive.h | 4 +- .../cmlibarchive/libarchive/archive_acl.c | 20 +- .../cmlibarchive/libarchive/archive_cryptor.c | 4 +- .../libarchive/archive_cryptor_private.h | 2 +- .../cmlibarchive/libarchive/archive_entry.c | 4 +- .../cmlibarchive/libarchive/archive_entry.h | 2 +- .../libarchive/archive_entry_sparse.c | 2 +- .../libarchive/archive_entry_xattr.c | 2 +- .../cmlibarchive/libarchive/archive_hmac.c | 2 +- .../libarchive/archive_hmac_private.h | 2 +- .../cmlibarchive/libarchive/archive_match.c | 2 +- .../libarchive/archive_openssl_evp_private.h | 2 +- .../libarchive/archive_openssl_hmac_private.h | 2 +- .../cmlibarchive/libarchive/archive_ppmd7.c | 2 +- .../cmlibarchive/libarchive/archive_ppmd8.c | 2 +- .../cmlibarchive/libarchive/archive_private.h | 4 +- .../cmlibarchive/libarchive/archive_read.c | 6 +- .../libarchive/archive_read_append_filter.c | 6 +- .../libarchive/archive_read_disk_posix.c | 2 +- .../libarchive/archive_read_disk_windows.c | 29 ++- .../libarchive/archive_read_extract2.c | 2 +- .../libarchive/archive_read_open_fd.c | 2 +- .../libarchive/archive_read_open_file.c | 2 +- .../libarchive/archive_read_open_filename.c | 4 +- .../libarchive/archive_read_open_memory.c | 2 +- .../archive_read_support_filter_bzip2.c | 4 +- .../archive_read_support_filter_compress.c | 2 +- .../archive_read_support_filter_gzip.c | 18 +- .../archive_read_support_filter_lz4.c | 6 +- .../archive_read_support_filter_lzop.c | 2 +- .../archive_read_support_filter_program.c | 6 +- .../archive_read_support_filter_rpm.c | 2 +- .../archive_read_support_filter_uu.c | 2 +- .../archive_read_support_filter_xz.c | 4 +- .../archive_read_support_filter_zstd.c | 4 +- .../archive_read_support_format_7zip.c | 55 +++-- .../archive_read_support_format_ar.c | 4 +- .../archive_read_support_format_cab.c | 10 +- .../archive_read_support_format_cpio.c | 4 +- .../archive_read_support_format_iso9660.c | 190 ++++++++++++++-- .../archive_read_support_format_lha.c | 2 +- .../archive_read_support_format_mtree.c | 2 +- .../archive_read_support_format_rar.c | 15 +- .../archive_read_support_format_rar5.c | 95 ++++++-- .../archive_read_support_format_raw.c | 2 +- .../archive_read_support_format_tar.c | 207 ++++++++++-------- .../archive_read_support_format_xar.c | 2 +- .../archive_read_support_format_zip.c | 21 +- .../cmlibarchive/libarchive/archive_string.c | 2 +- .../cmlibarchive/libarchive/archive_util.c | 6 +- .../cmlibarchive/libarchive/archive_write.c | 8 +- .../archive_write_add_filter_b64encode.c | 2 +- .../archive_write_add_filter_bzip2.c | 3 +- .../archive_write_add_filter_compress.c | 2 +- .../archive_write_add_filter_gzip.c | 3 +- .../archive_write_add_filter_uuencode.c | 2 +- .../libarchive/archive_write_add_filter_xz.c | 3 +- .../archive_write_add_filter_zstd.c | 3 +- .../libarchive/archive_write_disk_posix.c | 4 +- .../libarchive/archive_write_disk_windows.c | 51 +++-- .../libarchive/archive_write_open_fd.c | 2 +- .../libarchive/archive_write_open_file.c | 2 +- .../libarchive/archive_write_open_filename.c | 2 +- .../libarchive/archive_write_open_memory.c | 2 +- .../archive_write_set_format_7zip.c | 16 +- .../libarchive/archive_write_set_format_ar.c | 6 +- .../archive_write_set_format_cpio_binary.c | 2 +- .../archive_write_set_format_cpio_newc.c | 2 +- .../archive_write_set_format_cpio_odc.c | 2 +- .../archive_write_set_format_gnutar.c | 2 +- .../libarchive/archive_write_set_format_pax.c | 8 +- .../libarchive/archive_write_set_format_raw.c | 2 +- .../archive_write_set_format_shar.c | 2 +- .../archive_write_set_format_ustar.c | 2 +- .../archive_write_set_format_v7tar.c | 2 +- .../libarchive/archive_write_set_format_zip.c | 2 +- 223 files changed, 1175 insertions(+), 485 deletions(-) create mode 100644 Modules/Platform/Linker/Android-ASM.cmake create mode 100644 Modules/Platform/Linker/Android-C.cmake create mode 100644 Modules/Platform/Linker/Android-CXX.cmake create mode 100644 Modules/Platform/Linker/Android-GNU-ASM.cmake create mode 100644 Modules/Platform/Linker/Android-GNU-C.cmake create mode 100644 Modules/Platform/Linker/Android-GNU-CXX.cmake create mode 100644 Modules/Platform/Linker/Android-LLD-ASM.cmake create mode 100644 Modules/Platform/Linker/Android-LLD-C.cmake create mode 100644 Modules/Platform/Linker/Android-LLD-CXX.cmake create mode 100644 Modules/Platform/Linker/WindowsCE-C.cmake create mode 100644 Modules/Platform/Linker/WindowsCE-CXX.cmake create mode 100644 Modules/Platform/Linker/WindowsCE-MSVC-C.cmake create mode 100644 Modules/Platform/Linker/WindowsCE-MSVC-CXX.cmake create mode 100644 Modules/Platform/Linker/WindowsKernelModeDriver-C.cmake create mode 100644 Modules/Platform/Linker/WindowsKernelModeDriver-CXX.cmake create mode 100644 Modules/Platform/Linker/WindowsKernelModeDriver-MSVC-C.cmake create mode 100644 Modules/Platform/Linker/WindowsKernelModeDriver-MSVC-CXX.cmake create mode 100644 Modules/Platform/Linker/WindowsPhone-ASM.cmake create mode 100644 Modules/Platform/Linker/WindowsPhone-C.cmake create mode 100644 Modules/Platform/Linker/WindowsPhone-CXX.cmake create mode 100644 Modules/Platform/Linker/WindowsPhone-GNU-ASM.cmake create mode 100644 Modules/Platform/Linker/WindowsPhone-GNU-C.cmake create mode 100644 Modules/Platform/Linker/WindowsPhone-GNU-CXX.cmake create mode 100644 Modules/Platform/Linker/WindowsPhone-LLD-ASM.cmake create mode 100644 Modules/Platform/Linker/WindowsPhone-LLD-C.cmake create mode 100644 Modules/Platform/Linker/WindowsPhone-LLD-CXX.cmake create mode 100644 Modules/Platform/Linker/WindowsPhone-MSVC-ASM.cmake create mode 100644 Modules/Platform/Linker/WindowsPhone-MSVC-C.cmake create mode 100644 Modules/Platform/Linker/WindowsPhone-MSVC-CXX.cmake create mode 100644 Modules/Platform/Linker/WindowsStore-ASM.cmake create mode 100644 Modules/Platform/Linker/WindowsStore-C.cmake create mode 100644 Modules/Platform/Linker/WindowsStore-CXX.cmake create mode 100644 Modules/Platform/Linker/WindowsStore-GNU-ASM.cmake create mode 100644 Modules/Platform/Linker/WindowsStore-GNU-C.cmake create mode 100644 Modules/Platform/Linker/WindowsStore-GNU-CXX.cmake create mode 100644 Modules/Platform/Linker/WindowsStore-LLD-ASM.cmake create mode 100644 Modules/Platform/Linker/WindowsStore-LLD-C.cmake create mode 100644 Modules/Platform/Linker/WindowsStore-LLD-CXX.cmake create mode 100644 Modules/Platform/Linker/WindowsStore-MSVC-ASM.cmake create mode 100644 Modules/Platform/Linker/WindowsStore-MSVC-C.cmake create mode 100644 Modules/Platform/Linker/WindowsStore-MSVC-CXX.cmake delete mode 100644 Tests/RunCMake/GoogleTest/GoogleTest-discovery-flush-script-check-list.cmake create mode 100644 Tests/RunCMake/GoogleTest/GoogleTest-discovery-flush-script-check-list.cmake.in diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst index 122bb4eda..6c2d693f1 100644 --- a/Help/command/add_custom_command.rst +++ b/Help/command/add_custom_command.rst @@ -599,7 +599,8 @@ target is already built, the command will not execute. [WORKING_DIRECTORY dir] [COMMENT comment] [VERBATIM] - [COMMAND_EXPAND_LISTS]) + [COMMAND_EXPAND_LISTS] + [USES_TERMINAL]) This defines a new command that will be associated with building the specified ````. The ```` must be defined in the current diff --git a/Help/generator/Visual Studio 10 2010.rst b/Help/generator/Visual Studio 10 2010.rst index a36046a22..8b7e31da6 100644 --- a/Help/generator/Visual Studio 10 2010.rst +++ b/Help/generator/Visual Studio 10 2010.rst @@ -3,6 +3,7 @@ Visual Studio 10 2010 Removed. This once generated Visual Studio 10 2010 project files, but the generator has been removed since CMake 3.25. It is still possible -to build with VS 10 2010 tools using the :generator:`Visual Studio 14 2015` -(or above) generator with :variable:`CMAKE_GENERATOR_TOOLSET` set to -``v100``, or by using the :generator:`NMake Makefiles` generator. +to build with the VS 10 2010 toolset by also installing VS 2015 (or above) +and using the :generator:`Visual Studio 14 2015` (or above) generator with +:variable:`CMAKE_GENERATOR_TOOLSET` set to ``v100``, +or by using the :generator:`NMake Makefiles` generator. diff --git a/Help/generator/Visual Studio 11 2012.rst b/Help/generator/Visual Studio 11 2012.rst index 5ded24c86..99048bdd2 100644 --- a/Help/generator/Visual Studio 11 2012.rst +++ b/Help/generator/Visual Studio 11 2012.rst @@ -3,6 +3,7 @@ Visual Studio 11 2012 Removed. This once generated Visual Studio 11 2012 project files, but the generator has been removed since CMake 3.28. It is still possible -to build with VS 11 2012 tools using the :generator:`Visual Studio 14 2015` -(or above) generator with :variable:`CMAKE_GENERATOR_TOOLSET` set to ``v110``, +to build with the VS 11 2012 toolset by also installing VS 2015 (or above) +and using the :generator:`Visual Studio 14 2015` (or above) generator with +:variable:`CMAKE_GENERATOR_TOOLSET` set to ``v110``, or by using the :generator:`NMake Makefiles` generator. diff --git a/Help/generator/Visual Studio 12 2013.rst b/Help/generator/Visual Studio 12 2013.rst index 8d3b2c8d5..658907284 100644 --- a/Help/generator/Visual Studio 12 2013.rst +++ b/Help/generator/Visual Studio 12 2013.rst @@ -3,6 +3,7 @@ Visual Studio 12 2013 Removed. This once generated Visual Studio 12 2013 project files, but the generator has been removed since CMake 3.31. It is still possible -to build with VS 12 2013 tools using the :generator:`Visual Studio 14 2015` -(or above) generator with :variable:`CMAKE_GENERATOR_TOOLSET` set to ``v120``, +to build with the VS 12 2013 toolset by also installing VS 2015 (or above) +and using the :generator:`Visual Studio 14 2015` (or above) generator with +:variable:`CMAKE_GENERATOR_TOOLSET` set to ``v120``, or by using the :generator:`NMake Makefiles` generator. diff --git a/Help/generator/Visual Studio 9 2008.rst b/Help/generator/Visual Studio 9 2008.rst index 01d5af2b2..a5d953ac6 100644 --- a/Help/generator/Visual Studio 9 2008.rst +++ b/Help/generator/Visual Studio 9 2008.rst @@ -3,7 +3,7 @@ Visual Studio 9 2008 Removed. This once generated Visual Studio 9 2008 project files, but the generator has been removed since CMake 3.30. It is still possible -to build with VS 9 2008 tools using the :generator:`Visual Studio 14 2015` -generator (or above, and with VS 10 2010 also installed) with -:variable:`CMAKE_GENERATOR_TOOLSET` set to ``v90``, or by using -the :generator:`NMake Makefiles` generator. +to build with the VS 9 2008 toolset by also installing VS 10 2010 and +VS 2015 (or above) and using the :generator:`Visual Studio 14 2015` +generator (or above) with :variable:`CMAKE_GENERATOR_TOOLSET` set to ``v90``, +or by using the :generator:`NMake Makefiles` generator. diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst index cebe8f913..fc7a27d97 100644 --- a/Help/manual/cmake-developer.7.rst +++ b/Help/manual/cmake-developer.7.rst @@ -408,7 +408,9 @@ starting point. .. code-block:: cmake find_package(PkgConfig) - pkg_check_modules(PC_Foo QUIET Foo) + if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_Foo QUIET Foo) + endif() This should define some variables starting ``PC_Foo_`` that contain the information from the ``Foo.pc`` file. diff --git a/Help/policy/CMP0132.rst b/Help/policy/CMP0132.rst index c2a90c2a1..11a1212ca 100644 --- a/Help/policy/CMP0132.rst +++ b/Help/policy/CMP0132.rst @@ -3,6 +3,8 @@ CMP0132 .. versionadded:: 3.24 +Do not set compiler environment variables on first run. + Apart from when using the Xcode generator and some Visual Studio generators, CMake 3.23 and below will set environment variables like :envvar:`CC`, :envvar:`CXX`, etc. when the corresponding language is enabled. diff --git a/Help/policy/CMP0175.rst b/Help/policy/CMP0175.rst index f2c372d6e..a71aadfcc 100644 --- a/Help/policy/CMP0175.rst +++ b/Help/policy/CMP0175.rst @@ -24,8 +24,8 @@ following as errors that previously went unreported: ``POST_BUILD`` to be given. Previously, if none were given, ``POST_BUILD`` was assumed, or if multiple keywords were given, the last one was used. * The ``TARGET`` form does not accept ``DEPENDS``, ``DEPENDS_EXPLICIT_ONLY``, - ``DEPFILE``, ``IMPLICIT_DEPENDS``, ``MAIN_DEPENDENCY``, ``JOB_POOL``, - ``JOB_SERVER_AWARE``, or ``USES_TERMINAL`` keywords. + ``DEPFILE``, ``IMPLICIT_DEPENDS``, ``MAIN_DEPENDENCY``, ``JOB_POOL``, or + ``JOB_SERVER_AWARE`` keywords. * The ``TARGET`` form now requires at least one ``COMMAND`` to be given. * If a keyword expects a value to be given after it, but no value is provided, that was previously treated as though the keyword was not given at all. diff --git a/Help/release/3.29.rst b/Help/release/3.29.rst index 7d08b5468..fbde3c6a4 100644 --- a/Help/release/3.29.rst +++ b/Help/release/3.29.rst @@ -235,8 +235,8 @@ Changes made since CMake 3.29.0 include the following. to ``perMachine`` on their own schedule by setting ``CPACK_WIX_INSTALL_SCOPE``. -3.29.6, 3.29.7, 3.29.8 ----------------------- +3.29.6, 3.29.7, 3.29.8, 3.29.9 +------------------------------ * These versions made no changes to documented features or interfaces. Some implementation updates were made to support ecosystem changes diff --git a/Help/release/3.30.rst b/Help/release/3.30.rst index 32345bef7..9f01407e6 100644 --- a/Help/release/3.30.rst +++ b/Help/release/3.30.rst @@ -298,3 +298,10 @@ Changes made since CMake 3.30.0 include the following. This refines 3.30.3's behavior change to restore behavior of nested directories that call :command:`project` with the same project name, and it addresses the bug in the implementation introduced in 3.30.4. + +3.30.6 +------ + +* This version made no changes to documented features or interfaces. + Some implementation updates were made to support ecosystem changes + and/or fix regressions. diff --git a/Help/release/3.31.rst b/Help/release/3.31.rst index 606fb951f..7eea32a8d 100644 --- a/Help/release/3.31.rst +++ b/Help/release/3.31.rst @@ -257,3 +257,15 @@ Other Changes * The :command:`cmake_parse_arguments(PARSE_ARGV)` command now defines a variable for an empty string after a single-value keyword. See policy :policy:`CMP0174`. + +Updates +======= + +Changes made since CMake 3.31.0 include the following. + +3.31.1 +------ + +* This version made no changes to documented features or interfaces. + Some implementation updates were made to support ecosystem changes + and/or fix regressions. diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 1de476a77..aed185439 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -1410,7 +1410,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_THREAD_DEPENDENCIES chrono atomic) set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.86.0 AND NOT Boost_NO_WARN_NEW_VERSIONS) + if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.87.0 AND NOT Boost_NO_WARN_NEW_VERSIONS) message(WARNING "New Boost version may have incorrect or missing dependencies and imported targets") endif() endif() @@ -1685,7 +1685,7 @@ else() # _Boost_COMPONENT_HEADERS. See the instructions at the top of # _Boost_COMPONENT_DEPENDENCIES. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS} - "1.85.0" "1.85" "1.84.0" "1.84" + "1.86.0" "1.86" "1.85.0" "1.85" "1.84.0" "1.84" "1.83.0" "1.83" "1.82.0" "1.82" "1.81.0" "1.81" "1.80.0" "1.80" "1.79.0" "1.79" "1.78.0" "1.78" "1.77.0" "1.77" "1.76.0" "1.76" "1.75.0" "1.75" "1.74.0" "1.74" "1.73.0" "1.73" "1.72.0" "1.72" "1.71.0" "1.71" "1.70.0" "1.70" "1.69.0" "1.69" diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake index 66e65ad34..809fec7df 100644 --- a/Modules/FindImageMagick.cmake +++ b/Modules/FindImageMagick.cmake @@ -133,7 +133,9 @@ function(FIND_IMAGEMAGICK_API component header) NO_DEFAULT_PATH ) find_path(ImageMagick_${component}_ARCH_INCLUDE_DIR - NAMES magick/magick-baseconfig.h + NAMES + magick/magick-baseconfig.h + MagickCore/magick-baseconfig.h HINTS ${PC_${component}_INCLUDEDIR} ${PC_${component}_INCLUDE_DIRS} diff --git a/Modules/FindSQLite3.cmake b/Modules/FindSQLite3.cmake index 308a444d6..e5fead712 100644 --- a/Modules/FindSQLite3.cmake +++ b/Modules/FindSQLite3.cmake @@ -36,7 +36,9 @@ cmake_policy(PUSH) cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_ find_package(PkgConfig QUIET) -pkg_check_modules(PC_SQLite3 QUIET sqlite3) +if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_SQLite3 QUIET sqlite3) +endif() # Look for the necessary header find_path(SQLite3_INCLUDE_DIR NAMES sqlite3.h diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake index 0374b8f9b..afed307f4 100644 --- a/Modules/GoogleTestAddTests.cmake +++ b/Modules/GoogleTestAddTests.cmake @@ -4,23 +4,6 @@ cmake_minimum_required(VERSION 3.30) cmake_policy(SET CMP0174 NEW) # TODO: Remove this when we can update the above to 3.31 -# Overwrite possibly existing ${arg_CTEST_FILE} with empty file -set(flush_tests_MODE WRITE) - -# Flushes script to ${arg_CTEST_FILE} -macro(flush_script) - file(${flush_tests_MODE} "${arg_CTEST_FILE}" "${script}") - set(flush_tests_MODE APPEND PARENT_SCOPE) - - set(script "") -endmacro() - -# Flushes tests_buffer to tests -macro(flush_tests_buffer) - list(APPEND tests "${tests_buffer}") - set(tests_buffer "") -endmacro() - function(add_command name test_name) set(args "") foreach(arg ${ARGN}) @@ -31,10 +14,6 @@ function(add_command name test_name) endif() endforeach() string(APPEND script "${name}(${test_name} ${args})\n") - string(LENGTH "${script}" script_len) - if(${script_len} GREATER "50000") - flush_script() - endif() set(script "${script}" PARENT_SCOPE) endfunction() @@ -97,7 +76,12 @@ function(gtest_discover_tests_impl) set(script) set(suite) set(tests) - set(tests_buffer) + set(tests_buffer "") + + # If a file at ${arg_CTEST_FILE} already exists, we overwrite it. + # For performance reasons, we write to this file in chunks, and this variable + # is updated to APPEND after the first write. + set(file_write_mode WRITE) if(arg_TEST_FILTER) set(filter "--gtest_filter=${arg_TEST_FILTER}") @@ -229,25 +213,16 @@ function(gtest_discover_tests_impl) string(APPEND script " [==[${extra_args}]==]") endif() string(APPEND script ")\n") - string(LENGTH "${script}" script_len) - if(${script_len} GREATER "50000") - # flush_script() expects to set variables in the parent scope, so we - # need to create one since we actually want the changes in our scope - block(SCOPE_FOR VARIABLES) - flush_script() - endblock() - endif() + set(maybe_disabled "") if(suite MATCHES "^DISABLED_" OR test MATCHES "^DISABLED_") - add_command(set_tests_properties - "${guarded_testname}" - PROPERTIES DISABLED TRUE - ) + set(maybe_disabled DISABLED TRUE) endif() add_command(set_tests_properties "${guarded_testname}" PROPERTIES + ${maybe_disabled} WORKING_DIRECTORY "${arg_TEST_WORKING_DIR}" SKIP_REGULAR_EXPRESSION "\\[ SKIPPED \\]" ${arg_TEST_PROPERTIES} @@ -260,22 +235,39 @@ function(gtest_discover_tests_impl) string(REPLACE [[;]] [[\\;]] testname "${testname}") list(APPEND tests_buffer "${testname}") list(LENGTH tests_buffer tests_buffer_length) - if(${tests_buffer_length} GREATER "250") - flush_tests_buffer() + if(tests_buffer_length GREATER "250") + # Chunk updates to the final "tests" variable, keeping the + # "tests_buffer" variable that we append each test to relatively + # small. This mitigates worsening performance impacts for the + # corner case of having many thousands of tests. + list(APPEND tests "${tests_buffer}") + set(tests_buffer "") endif() endif() endif() + + # If we've built up a sizable script so far, write it out as a chunk now + # so we don't accumulate a massive string to write at the end + string(LENGTH "${script}" script_len) + if(${script_len} GREATER "50000") + file(${file_write_mode} "${arg_CTEST_FILE}" "${script}") + set(file_write_mode APPEND) + set(script "") + endif() + endif() endforeach() + if(NOT tests_buffer STREQUAL "") + list(APPEND tests "${tests_buffer}") + endif() # Create a list of all discovered tests, which users may use to e.g. set # properties on the tests - flush_tests_buffer() add_command(set "" ${arg_TEST_LIST} "${tests}") - # Write CTest script - flush_script() + # Write remaining content to the CTest script + file(${file_write_mode} "${arg_CTEST_FILE}" "${script}") endfunction() diff --git a/Modules/Internal/CMakeASMLinkerInformation.cmake b/Modules/Internal/CMakeASMLinkerInformation.cmake index 5f81b1feb..2d547dc47 100644 --- a/Modules/Internal/CMakeASMLinkerInformation.cmake +++ b/Modules/Internal/CMakeASMLinkerInformation.cmake @@ -29,7 +29,7 @@ endif() # We specify the platform linker information in the system file. if (NOT _INCLUDED_FILE) - include(Platform/Linker/${CMAKE_SYSTEM_NAME}-ASM${ASM_DIALECT} OPTIONAL) + include(Platform/Linker/${CMAKE_EFFECTIVE_SYSTEM_NAME}-ASM${ASM_DIALECT} OPTIONAL) endif () set(CMAKE_ASM${ASM_DIALECT}_LINKER_INFORMATION_LOADED 1) diff --git a/Modules/Internal/CMakeCLinkerInformation.cmake b/Modules/Internal/CMakeCLinkerInformation.cmake index d918f8488..ddc98278a 100644 --- a/Modules/Internal/CMakeCLinkerInformation.cmake +++ b/Modules/Internal/CMakeCLinkerInformation.cmake @@ -31,7 +31,7 @@ endif() # We specify the platform linker information in the system file. if (NOT _INCLUDED_FILE) - include(Platform/Linker/${CMAKE_SYSTEM_NAME}-C OPTIONAL) + include(Platform/Linker/${CMAKE_EFFECTIVE_SYSTEM_NAME}-C OPTIONAL) endif () _cmake_common_linker_platform_flags(C) diff --git a/Modules/Internal/CMakeCUDALinkerInformation.cmake b/Modules/Internal/CMakeCUDALinkerInformation.cmake index 4081e50be..1d375f2bd 100644 --- a/Modules/Internal/CMakeCUDALinkerInformation.cmake +++ b/Modules/Internal/CMakeCUDALinkerInformation.cmake @@ -31,7 +31,7 @@ endif() # We specify the platform linker information in the system file. if (NOT _INCLUDED_FILE) - include(Platform/Linker/${CMAKE_SYSTEM_NAME}-CUDA OPTIONAL) + include(Platform/Linker/${CMAKE_EFFECTIVE_SYSTEM_NAME}-CUDA OPTIONAL) endif () _cmake_common_linker_platform_flags(CUDA) diff --git a/Modules/Internal/CMakeCXXLinkerInformation.cmake b/Modules/Internal/CMakeCXXLinkerInformation.cmake index 3929bbbb0..2398b5073 100644 --- a/Modules/Internal/CMakeCXXLinkerInformation.cmake +++ b/Modules/Internal/CMakeCXXLinkerInformation.cmake @@ -31,7 +31,7 @@ endif() # We specify the platform linker information in the system file. if (NOT _INCLUDED_FILE) - include(Platform/Linker/${CMAKE_SYSTEM_NAME}-CXX OPTIONAL) + include(Platform/Linker/${CMAKE_EFFECTIVE_SYSTEM_NAME}-CXX OPTIONAL) endif () _cmake_common_linker_platform_flags(CXX) diff --git a/Modules/Internal/CMakeFortranLinkerInformation.cmake b/Modules/Internal/CMakeFortranLinkerInformation.cmake index a39f3deef..cddd0e9cc 100644 --- a/Modules/Internal/CMakeFortranLinkerInformation.cmake +++ b/Modules/Internal/CMakeFortranLinkerInformation.cmake @@ -31,7 +31,7 @@ endif() # We specify the platform linker information in the system file. if (NOT _INCLUDED_FILE) - include(Platform/Linker/${CMAKE_SYSTEM_NAME}-Fortran OPTIONAL) + include(Platform/Linker/${CMAKE_EFFECTIVE_SYSTEM_NAME}-Fortran OPTIONAL) endif () _cmake_common_linker_platform_flags(Fortran) diff --git a/Modules/Internal/CMakeHIPLinkerInformation.cmake b/Modules/Internal/CMakeHIPLinkerInformation.cmake index d37d66d9e..e996889ef 100644 --- a/Modules/Internal/CMakeHIPLinkerInformation.cmake +++ b/Modules/Internal/CMakeHIPLinkerInformation.cmake @@ -31,7 +31,7 @@ endif() # We specify the platform linker information in the system file. if (NOT _INCLUDED_FILE) - include(Platform/Linker/${CMAKE_SYSTEM_NAME}-HIP OPTIONAL) + include(Platform/Linker/${CMAKE_EFFECTIVE_SYSTEM_NAME}-HIP OPTIONAL) endif () _cmake_common_linker_platform_flags(HIP) diff --git a/Modules/Internal/CMakeOBJCLinkerInformation.cmake b/Modules/Internal/CMakeOBJCLinkerInformation.cmake index ea9288008..a26fa4231 100644 --- a/Modules/Internal/CMakeOBJCLinkerInformation.cmake +++ b/Modules/Internal/CMakeOBJCLinkerInformation.cmake @@ -31,7 +31,7 @@ endif() # We specify the platform linker information in the system file. if (NOT _INCLUDED_FILE) - include(Platform/Linker/${CMAKE_SYSTEM_NAME}-OBJC OPTIONAL) + include(Platform/Linker/${CMAKE_EFFECTIVE_SYSTEM_NAME}-OBJC OPTIONAL) endif () _cmake_common_linker_platform_flags(OBJC) diff --git a/Modules/Internal/CMakeOBJCXXLinkerInformation.cmake b/Modules/Internal/CMakeOBJCXXLinkerInformation.cmake index 3b51ba77b..d61dd1a2a 100644 --- a/Modules/Internal/CMakeOBJCXXLinkerInformation.cmake +++ b/Modules/Internal/CMakeOBJCXXLinkerInformation.cmake @@ -31,7 +31,7 @@ endif() # We specify the platform linker information in the system file. if (NOT _INCLUDED_FILE) - include(Platform/Linker/${CMAKE_SYSTEM_NAME}-OBJCXX OPTIONAL) + include(Platform/Linker/${CMAKE_EFFECTIVE_SYSTEM_NAME}-OBJCXX OPTIONAL) endif () _cmake_common_linker_platform_flags(OBJCXX) diff --git a/Modules/Internal/CMakeSwiftLinkerInformation.cmake b/Modules/Internal/CMakeSwiftLinkerInformation.cmake index 6d1881fa1..f3a1d07cb 100644 --- a/Modules/Internal/CMakeSwiftLinkerInformation.cmake +++ b/Modules/Internal/CMakeSwiftLinkerInformation.cmake @@ -31,7 +31,7 @@ endif() # We specify the platform linker information in the system file. if (NOT _INCLUDED_FILE) - include(Platform/Linker/${CMAKE_SYSTEM_NAME}-Swift OPTIONAL) + include(Platform/Linker/${CMAKE_EFFECTIVE_SYSTEM_NAME}-Swift OPTIONAL) endif () _cmake_common_linker_platform_flags(Swift) diff --git a/Modules/Platform/Linker/AIX-AIX.cmake b/Modules/Platform/Linker/AIX-AIX.cmake index 36d795936..553168b15 100644 --- a/Modules/Platform/Linker/AIX-AIX.cmake +++ b/Modules/Platform/Linker/AIX-AIX.cmake @@ -6,5 +6,6 @@ include_guard() macro(__aix_linker_aix lang) + set(CMAKE_${lang}_PLATFORM_LINKER_ID AIX) set(CMAKE_${lang}_LINK_LIBRARIES_PROCESSING ORDER=REVERSE DEDUPLICATION=ALL) endmacro() diff --git a/Modules/Platform/Linker/Android-ASM.cmake b/Modules/Platform/Linker/Android-ASM.cmake new file mode 100644 index 000000000..8e44bafe8 --- /dev/null +++ b/Modules/Platform/Linker/Android-ASM.cmake @@ -0,0 +1,5 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# GNU is the default linker +include(Platform/Linker/Android-GNU-ASM) diff --git a/Modules/Platform/Linker/Android-C.cmake b/Modules/Platform/Linker/Android-C.cmake new file mode 100644 index 000000000..d3df948fa --- /dev/null +++ b/Modules/Platform/Linker/Android-C.cmake @@ -0,0 +1,5 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# GNU is the default linker +include(Platform/Linker/Android-GNU-C) diff --git a/Modules/Platform/Linker/Android-CXX.cmake b/Modules/Platform/Linker/Android-CXX.cmake new file mode 100644 index 000000000..aff308bc8 --- /dev/null +++ b/Modules/Platform/Linker/Android-CXX.cmake @@ -0,0 +1,5 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# GNU is the default linker +include(Platform/Linker/Android-GNU-CXX) diff --git a/Modules/Platform/Linker/Android-GNU-ASM.cmake b/Modules/Platform/Linker/Android-GNU-ASM.cmake new file mode 100644 index 000000000..bfef8b9f7 --- /dev/null +++ b/Modules/Platform/Linker/Android-GNU-ASM.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Linux-GNU-ASM) diff --git a/Modules/Platform/Linker/Android-GNU-C.cmake b/Modules/Platform/Linker/Android-GNU-C.cmake new file mode 100644 index 000000000..2d0efda7e --- /dev/null +++ b/Modules/Platform/Linker/Android-GNU-C.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Linux-GNU-C) diff --git a/Modules/Platform/Linker/Android-GNU-CXX.cmake b/Modules/Platform/Linker/Android-GNU-CXX.cmake new file mode 100644 index 000000000..33c46d53a --- /dev/null +++ b/Modules/Platform/Linker/Android-GNU-CXX.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Linux-GNU-CXX) diff --git a/Modules/Platform/Linker/Android-LLD-ASM.cmake b/Modules/Platform/Linker/Android-LLD-ASM.cmake new file mode 100644 index 000000000..870e59e9d --- /dev/null +++ b/Modules/Platform/Linker/Android-LLD-ASM.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Linux-LLD-ASM) diff --git a/Modules/Platform/Linker/Android-LLD-C.cmake b/Modules/Platform/Linker/Android-LLD-C.cmake new file mode 100644 index 000000000..efeeb1622 --- /dev/null +++ b/Modules/Platform/Linker/Android-LLD-C.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Linux-LLD-C) diff --git a/Modules/Platform/Linker/Android-LLD-CXX.cmake b/Modules/Platform/Linker/Android-LLD-CXX.cmake new file mode 100644 index 000000000..46a516c10 --- /dev/null +++ b/Modules/Platform/Linker/Android-LLD-CXX.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Linux-LLD-CXX) diff --git a/Modules/Platform/Linker/Apple-AppleClang.cmake b/Modules/Platform/Linker/Apple-AppleClang.cmake index 7582ae9e5..643cbbd40 100644 --- a/Modules/Platform/Linker/Apple-AppleClang.cmake +++ b/Modules/Platform/Linker/Apple-AppleClang.cmake @@ -6,6 +6,7 @@ include_guard() macro(__apple_linker_appleclang lang) + set(CMAKE_${lang}_PLATFORM_LINKER_ID AppleClang) set(CMAKE_${lang}_LINK_LIBRARIES_PROCESSING ORDER=REVERSE DEDUPLICATION=ALL) # Features for LINK_LIBRARY generator expression diff --git a/Modules/Platform/Linker/Apple-LLD-C.cmake b/Modules/Platform/Linker/Apple-LLD-C.cmake index e38b1b7e8..64d959166 100644 --- a/Modules/Platform/Linker/Apple-LLD-C.cmake +++ b/Modules/Platform/Linker/Apple-LLD-C.cmake @@ -2,3 +2,5 @@ # file Copyright.txt or https://cmake.org/licensing for details. include(Platform/Linker/Apple-AppleClang-C) + +set(CMAKE_C_PLATFORM_LINKER_ID LLD) diff --git a/Modules/Platform/Linker/Apple-LLD-CXX.cmake b/Modules/Platform/Linker/Apple-LLD-CXX.cmake index 4e4a9cad1..deaa5588a 100644 --- a/Modules/Platform/Linker/Apple-LLD-CXX.cmake +++ b/Modules/Platform/Linker/Apple-LLD-CXX.cmake @@ -2,3 +2,5 @@ # file Copyright.txt or https://cmake.org/licensing for details. include(Platform/Linker/Apple-AppleClang-CXX) + +set(CMAKE_CXX_PLATFORM_LINKER_ID LLD) diff --git a/Modules/Platform/Linker/Apple-LLD-OBJC.cmake b/Modules/Platform/Linker/Apple-LLD-OBJC.cmake index ff18785a1..18790343a 100644 --- a/Modules/Platform/Linker/Apple-LLD-OBJC.cmake +++ b/Modules/Platform/Linker/Apple-LLD-OBJC.cmake @@ -2,3 +2,5 @@ # file Copyright.txt or https://cmake.org/licensing for details. include(Platform/Linker/Apple-AppleClang-OBJC) + +set(CMAKE_OBJC_PLATFORM_LINKER_ID LLD) diff --git a/Modules/Platform/Linker/Apple-LLD-OBJCXX.cmake b/Modules/Platform/Linker/Apple-LLD-OBJCXX.cmake index ba9289025..71844d9f2 100644 --- a/Modules/Platform/Linker/Apple-LLD-OBJCXX.cmake +++ b/Modules/Platform/Linker/Apple-LLD-OBJCXX.cmake @@ -2,3 +2,5 @@ # file Copyright.txt or https://cmake.org/licensing for details. include(Platform/Linker/Apple-AppleClang-OBJCXX) + +set(CMAKE_OBJCXX_PLATFORM_LINKER_ID LLD) diff --git a/Modules/Platform/Linker/Apple-MOLD-C.cmake b/Modules/Platform/Linker/Apple-MOLD-C.cmake index e38b1b7e8..14347bbce 100644 --- a/Modules/Platform/Linker/Apple-MOLD-C.cmake +++ b/Modules/Platform/Linker/Apple-MOLD-C.cmake @@ -2,3 +2,5 @@ # file Copyright.txt or https://cmake.org/licensing for details. include(Platform/Linker/Apple-AppleClang-C) + +set(CMAKE_C_PLATFORM_LINKER_ID MOLD) diff --git a/Modules/Platform/Linker/Apple-MOLD-CXX.cmake b/Modules/Platform/Linker/Apple-MOLD-CXX.cmake index 4e4a9cad1..416b8b541 100644 --- a/Modules/Platform/Linker/Apple-MOLD-CXX.cmake +++ b/Modules/Platform/Linker/Apple-MOLD-CXX.cmake @@ -2,3 +2,5 @@ # file Copyright.txt or https://cmake.org/licensing for details. include(Platform/Linker/Apple-AppleClang-CXX) + +set(CMAKE_CXX_PLATFORM_LINKER_ID MOLD) diff --git a/Modules/Platform/Linker/Apple-MOLD-OBJC.cmake b/Modules/Platform/Linker/Apple-MOLD-OBJC.cmake index ff18785a1..e18281b21 100644 --- a/Modules/Platform/Linker/Apple-MOLD-OBJC.cmake +++ b/Modules/Platform/Linker/Apple-MOLD-OBJC.cmake @@ -2,3 +2,5 @@ # file Copyright.txt or https://cmake.org/licensing for details. include(Platform/Linker/Apple-AppleClang-OBJC) + +set(CMAKE_OBJC_PLATFORM_LINKER_ID MOLD) diff --git a/Modules/Platform/Linker/Apple-MOLD-OBJCXX.cmake b/Modules/Platform/Linker/Apple-MOLD-OBJCXX.cmake index ba9289025..3a7d48d0d 100644 --- a/Modules/Platform/Linker/Apple-MOLD-OBJCXX.cmake +++ b/Modules/Platform/Linker/Apple-MOLD-OBJCXX.cmake @@ -2,3 +2,5 @@ # file Copyright.txt or https://cmake.org/licensing for details. include(Platform/Linker/Apple-AppleClang-OBJCXX) + +set(CMAKE_OBJCXX_PLATFORM_LINKER_ID MOLD) diff --git a/Modules/Platform/Linker/CYGWIN-GNU.cmake b/Modules/Platform/Linker/CYGWIN-GNU.cmake index 8e5b97093..0ac407f8a 100644 --- a/Modules/Platform/Linker/CYGWIN-GNU.cmake +++ b/Modules/Platform/Linker/CYGWIN-GNU.cmake @@ -8,6 +8,7 @@ include_guard() include(Platform/Linker/GNU) macro(__cygwin_linker_gnu lang) + set(CMAKE_${lang}_PLATFORM_LINKER_ID GNU) if(CMAKE_${lang}_COMPILER_LINKER) __cmake_set_whole_archive_feature("${CMAKE_${lang}_COMPILER_LINKER}" "${lang}") endif() diff --git a/Modules/Platform/Linker/CYGWIN-LLD.cmake b/Modules/Platform/Linker/CYGWIN-LLD.cmake index 39a3c594a..1b637e2b6 100644 --- a/Modules/Platform/Linker/CYGWIN-LLD.cmake +++ b/Modules/Platform/Linker/CYGWIN-LLD.cmake @@ -12,5 +12,6 @@ include(Platform/Linker/CYGWIN-GNU) macro(__cygwin_linker_lld lang) __cygwin_linker_gnu(${lang}) + set(CMAKE_${lang}_PLATFORM_LINKER_ID LLD) set(CMAKE_${lang}_LINK_LIBRARIES_PROCESSING ORDER=REVERSE DEDUPLICATION=ALL) endmacro() diff --git a/Modules/Platform/Linker/FreeBSD-GNU.cmake b/Modules/Platform/Linker/FreeBSD-GNU.cmake index f88485702..5b26c034b 100644 --- a/Modules/Platform/Linker/FreeBSD-GNU.cmake +++ b/Modules/Platform/Linker/FreeBSD-GNU.cmake @@ -8,6 +8,7 @@ include_guard() include(Platform/Linker/GNU) macro(__freebsd_linker_gnu lang) + set(CMAKE_${lang}_PLATFORM_LINKER_ID GNU) if(CMAKE_${lang}_COMPILER_LINKER) __cmake_set_whole_archive_feature("${CMAKE_${lang}_COMPILER_LINKER}" "${lang}") endif() diff --git a/Modules/Platform/Linker/FreeBSD-LLD.cmake b/Modules/Platform/Linker/FreeBSD-LLD.cmake index 133f80c5d..19f4df59d 100644 --- a/Modules/Platform/Linker/FreeBSD-LLD.cmake +++ b/Modules/Platform/Linker/FreeBSD-LLD.cmake @@ -12,5 +12,6 @@ include(Platform/Linker/FreeBSD-GNU) macro(__freebsd_linker_lld lang) __freebsd_linker_gnu(${lang}) + set(CMAKE_${lang}_PLATFORM_LINKER_ID LLD) set(CMAKE_${lang}_LINK_LIBRARIES_PROCESSING ORDER=REVERSE DEDUPLICATION=ALL) endmacro() diff --git a/Modules/Platform/Linker/GNU-GNU.cmake b/Modules/Platform/Linker/GNU-GNU.cmake index a1adf14a6..274b87664 100644 --- a/Modules/Platform/Linker/GNU-GNU.cmake +++ b/Modules/Platform/Linker/GNU-GNU.cmake @@ -8,6 +8,7 @@ include_guard() include(Platform/Linker/GNU) macro(__gnu_linker_gnu lang) + set(CMAKE_${lang}_PLATFORM_LINKER_ID GNU) if(CMAKE_${lang}_COMPILER_LINKER) __cmake_set_whole_archive_feature("${CMAKE_${lang}_COMPILER_LINKER}" "${lang}") endif() diff --git a/Modules/Platform/Linker/Linux-GNU.cmake b/Modules/Platform/Linker/Linux-GNU.cmake index 6668141ae..0cffafbdf 100644 --- a/Modules/Platform/Linker/Linux-GNU.cmake +++ b/Modules/Platform/Linker/Linux-GNU.cmake @@ -8,6 +8,7 @@ include_guard() include(Platform/Linker/GNU) macro(__linux_linker_gnu lang) + set(CMAKE_${lang}_PLATFORM_LINKER_ID GNU) if(CMAKE_${lang}_COMPILER_LINKER) __cmake_set_whole_archive_feature("${CMAKE_${lang}_COMPILER_LINKER}" "${lang}") endif() diff --git a/Modules/Platform/Linker/Linux-GNUgold-ASM.cmake b/Modules/Platform/Linker/Linux-GNUgold-ASM.cmake index bfef8b9f7..54b45545b 100644 --- a/Modules/Platform/Linker/Linux-GNUgold-ASM.cmake +++ b/Modules/Platform/Linker/Linux-GNUgold-ASM.cmake @@ -2,3 +2,5 @@ # file Copyright.txt or https://cmake.org/licensing for details. include(Platform/Linker/Linux-GNU-ASM) + +set(CMAKE_ASM_PLATFORM_LINKER_ID GNUgold) diff --git a/Modules/Platform/Linker/Linux-GNUgold-C.cmake b/Modules/Platform/Linker/Linux-GNUgold-C.cmake index 2d0efda7e..929ac8848 100644 --- a/Modules/Platform/Linker/Linux-GNUgold-C.cmake +++ b/Modules/Platform/Linker/Linux-GNUgold-C.cmake @@ -2,3 +2,5 @@ # file Copyright.txt or https://cmake.org/licensing for details. include(Platform/Linker/Linux-GNU-C) + +set(CMAKE_C_PLATFORM_LINKER_ID GNUgold) diff --git a/Modules/Platform/Linker/Linux-GNUgold-CUDA.cmake b/Modules/Platform/Linker/Linux-GNUgold-CUDA.cmake index d67dc943c..0dc4ba2bb 100644 --- a/Modules/Platform/Linker/Linux-GNUgold-CUDA.cmake +++ b/Modules/Platform/Linker/Linux-GNUgold-CUDA.cmake @@ -2,3 +2,5 @@ # file Copyright.txt or https://cmake.org/licensing for details. include(Platform/Linker/Linux-GNU-CUDA) + +set(CMAKE_CUDA_PLATFORM_LINKER_ID GNUgold) diff --git a/Modules/Platform/Linker/Linux-GNUgold-CXX.cmake b/Modules/Platform/Linker/Linux-GNUgold-CXX.cmake index 33c46d53a..f390248f4 100644 --- a/Modules/Platform/Linker/Linux-GNUgold-CXX.cmake +++ b/Modules/Platform/Linker/Linux-GNUgold-CXX.cmake @@ -2,3 +2,5 @@ # file Copyright.txt or https://cmake.org/licensing for details. include(Platform/Linker/Linux-GNU-CXX) + +set(CMAKE_CXX_PLATFORM_LINKER_ID GNUgold) diff --git a/Modules/Platform/Linker/Linux-GNUgold-Fortran.cmake b/Modules/Platform/Linker/Linux-GNUgold-Fortran.cmake index a01acda3a..531d52469 100644 --- a/Modules/Platform/Linker/Linux-GNUgold-Fortran.cmake +++ b/Modules/Platform/Linker/Linux-GNUgold-Fortran.cmake @@ -2,3 +2,5 @@ # file Copyright.txt or https://cmake.org/licensing for details. include(Platform/Linker/Linux-GNU-Fortran) + +set(CMAKE_Fortran_PLATFORM_LINKER_ID GNUgold) diff --git a/Modules/Platform/Linker/Linux-GNUgold-HIP.cmake b/Modules/Platform/Linker/Linux-GNUgold-HIP.cmake index 6d1e4923f..0b77210dc 100644 --- a/Modules/Platform/Linker/Linux-GNUgold-HIP.cmake +++ b/Modules/Platform/Linker/Linux-GNUgold-HIP.cmake @@ -2,3 +2,5 @@ # file Copyright.txt or https://cmake.org/licensing for details. include(Platform/Linker/Linux-GNU-HIP) + +set(CMAKE_HIP_PLATFORM_LINKER_ID GNUgold) diff --git a/Modules/Platform/Linker/Linux-LLD.cmake b/Modules/Platform/Linker/Linux-LLD.cmake index afe5d1c77..86eedd852 100644 --- a/Modules/Platform/Linker/Linux-LLD.cmake +++ b/Modules/Platform/Linker/Linux-LLD.cmake @@ -12,5 +12,6 @@ include(Platform/Linker/Linux-GNU) macro(__linux_linker_lld lang) __linux_linker_gnu(${lang}) + set(CMAKE_${lang}_PLATFORM_LINKER_ID LLD) set(CMAKE_${lang}_LINK_LIBRARIES_PROCESSING ORDER=REVERSE DEDUPLICATION=ALL) endmacro() diff --git a/Modules/Platform/Linker/Linux-MOLD.cmake b/Modules/Platform/Linker/Linux-MOLD.cmake index 672e699d0..2a3d9dc5a 100644 --- a/Modules/Platform/Linker/Linux-MOLD.cmake +++ b/Modules/Platform/Linker/Linux-MOLD.cmake @@ -12,5 +12,7 @@ include(Platform/Linker/Linux-GNU) macro(__linux_linker_mold lang) __linux_linker_gnu(${lang}) + + set(CMAKE_C_PLATFORM_LINKER_ID MOLD) set(CMAKE_${lang}_LINK_LIBRARIES_PROCESSING ORDER=REVERSE DEDUPLICATION=ALL) endmacro() diff --git a/Modules/Platform/Linker/NetBSD-GNU.cmake b/Modules/Platform/Linker/NetBSD-GNU.cmake index f06e491ba..226afcd73 100644 --- a/Modules/Platform/Linker/NetBSD-GNU.cmake +++ b/Modules/Platform/Linker/NetBSD-GNU.cmake @@ -8,6 +8,7 @@ include_guard() include(Platform/Linker/GNU) macro(__netbsd_linker_gnu lang) + set(CMAKE_${lang}_PLATFORM_LINKER_ID GNU) if(CMAKE_${lang}_COMPILER_LINKER) __cmake_set_whole_archive_feature("${CMAKE_${lang}_COMPILER_LINKER}" "${lang}") endif() diff --git a/Modules/Platform/Linker/OpenBSD-GNU.cmake b/Modules/Platform/Linker/OpenBSD-GNU.cmake index b30e4679f..c5821bbf0 100644 --- a/Modules/Platform/Linker/OpenBSD-GNU.cmake +++ b/Modules/Platform/Linker/OpenBSD-GNU.cmake @@ -8,6 +8,7 @@ include_guard() include(Platform/Linker/GNU) macro(__openbsd_linker_gnu lang) + set(CMAKE_${lang}_PLATFORM_LINKER_ID GNU) if(CMAKE_${lang}_COMPILER_LINKER) __cmake_set_whole_archive_feature("${CMAKE_${lang}_COMPILER_LINKER}" "${lang}") endif() diff --git a/Modules/Platform/Linker/OpenBSD-LLD.cmake b/Modules/Platform/Linker/OpenBSD-LLD.cmake index 522a232f7..05a101779 100644 --- a/Modules/Platform/Linker/OpenBSD-LLD.cmake +++ b/Modules/Platform/Linker/OpenBSD-LLD.cmake @@ -12,5 +12,6 @@ include(Platform/Linker/OpenBSD-GNU) macro(__openbsd_linker_lld lang) __openbsd_linker_gnu(${lang}) + set(CMAKE_${lang}_PLATFORM_LINKER_ID LLD) set(CMAKE_${lang}_LINK_LIBRARIES_PROCESSING ORDER=REVERSE DEDUPLICATION=ALL) endmacro() diff --git a/Modules/Platform/Linker/SerenityOS-GNU.cmake b/Modules/Platform/Linker/SerenityOS-GNU.cmake index 9b06bfb67..45f6505ef 100644 --- a/Modules/Platform/Linker/SerenityOS-GNU.cmake +++ b/Modules/Platform/Linker/SerenityOS-GNU.cmake @@ -8,6 +8,7 @@ include_guard() include(Platform/Linker/GNU) macro(__serenityos_linker_gnu lang) + set(CMAKE_${lang}_PLATFORM_LINKER_ID GNU) if(CMAKE_${lang}_COMPILER_LINKER) __cmake_set_whole_archive_feature("${CMAKE_${lang}_COMPILER_LINKER}" "${lang}") endif() diff --git a/Modules/Platform/Linker/SerenityOS-LLD.cmake b/Modules/Platform/Linker/SerenityOS-LLD.cmake index 9f34e79a3..f3c038934 100644 --- a/Modules/Platform/Linker/SerenityOS-LLD.cmake +++ b/Modules/Platform/Linker/SerenityOS-LLD.cmake @@ -12,5 +12,6 @@ include(Platform/Linker/SerenityOS-GNU) macro(__serenityos_linker_lld lang) __serenityos_linker_gnu(${lang}) + set(CMAKE_${lang}_PLATFORM_LINKER_ID LLD) set(CMAKE_${lang}_LINK_LIBRARIES_PROCESSING ORDER=REVERSE DEDUPLICATION=ALL) endmacro() diff --git a/Modules/Platform/Linker/SunOS-GNU.cmake b/Modules/Platform/Linker/SunOS-GNU.cmake index 693e31a46..ae9697d41 100644 --- a/Modules/Platform/Linker/SunOS-GNU.cmake +++ b/Modules/Platform/Linker/SunOS-GNU.cmake @@ -8,6 +8,7 @@ include_guard() include(Platform/Linker/GNU) macro(__sunos_linker_gnu lang) + set(CMAKE_${lang}_PLATFORM_LINKER_ID GNU) if(CMAKE_${lang}_COMPILER_LINKER) __cmake_set_whole_archive_feature("${CMAKE_${lang}_COMPILER_LINKER}" "${lang}") endif() diff --git a/Modules/Platform/Linker/SunOS-Solaris.cmake b/Modules/Platform/Linker/SunOS-Solaris.cmake index cf82bf8d5..324108c86 100644 --- a/Modules/Platform/Linker/SunOS-Solaris.cmake +++ b/Modules/Platform/Linker/SunOS-Solaris.cmake @@ -9,6 +9,7 @@ block(SCOPE_FOR POLICIES) cmake_policy(SET CMP0054 NEW) macro(__sunos_linker_solaris lang) + set(CMAKE_${lang}_PLATFORM_LINKER_ID Solaris) # Features for LINK_LIBRARY generator expression ## WHOLE_ARCHIVE: Force loading all members of an archive if (CMAKE_SYSTEM_VERSION VERSION_GREATER "5.10") diff --git a/Modules/Platform/Linker/Windows-GNU.cmake b/Modules/Platform/Linker/Windows-GNU.cmake index a5c4417aa..144b03e28 100644 --- a/Modules/Platform/Linker/Windows-GNU.cmake +++ b/Modules/Platform/Linker/Windows-GNU.cmake @@ -8,6 +8,7 @@ include_guard() include(Platform/Linker/GNU) macro(__windows_linker_gnu lang) + set(CMAKE_${lang}_PLATFORM_LINKER_ID GNU) if(CMAKE_${lang}_COMPILER_LINKER) __cmake_set_whole_archive_feature("${CMAKE_${lang}_COMPILER_LINKER}" "${lang}") endif() diff --git a/Modules/Platform/Linker/Windows-LLD.cmake b/Modules/Platform/Linker/Windows-LLD.cmake index f2dde1ad3..5054745ca 100644 --- a/Modules/Platform/Linker/Windows-LLD.cmake +++ b/Modules/Platform/Linker/Windows-LLD.cmake @@ -9,6 +9,7 @@ block(SCOPE_FOR POLICIES) cmake_policy(SET CMP0054 NEW) macro(__windows_linker_lld lang) + set(CMAKE_${lang}_PLATFORM_LINKER_ID LLD) # Features for LINK_LIBRARY generator expression if(CMAKE_${lang}_COMPILER_LINKER_FRONTEND_VARIANT STREQUAL "GNU") include(Platform/Linker/Windows-GNU) diff --git a/Modules/Platform/Linker/Windows-MSVC.cmake b/Modules/Platform/Linker/Windows-MSVC.cmake index 2eb571392..18c21029e 100644 --- a/Modules/Platform/Linker/Windows-MSVC.cmake +++ b/Modules/Platform/Linker/Windows-MSVC.cmake @@ -17,6 +17,7 @@ if(MSVC_VERSION GREATER "1900") endif() macro(__windows_linker_msvc lang) + set(CMAKE_${lang}_PLATFORM_LINKER_ID MSVC) set(CMAKE_${lang}_LINK_LIBRARIES_PROCESSING ORDER=FORWARD DEDUPLICATION=ALL) # Features for LINK_LIBRARY generator expression diff --git a/Modules/Platform/Linker/WindowsCE-C.cmake b/Modules/Platform/Linker/WindowsCE-C.cmake new file mode 100644 index 000000000..2e30d91e1 --- /dev/null +++ b/Modules/Platform/Linker/WindowsCE-C.cmake @@ -0,0 +1,5 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# MSVC is the default linker +include(Platform/Linker/WindowsCE-MSVC-C) diff --git a/Modules/Platform/Linker/WindowsCE-CXX.cmake b/Modules/Platform/Linker/WindowsCE-CXX.cmake new file mode 100644 index 000000000..e61470c41 --- /dev/null +++ b/Modules/Platform/Linker/WindowsCE-CXX.cmake @@ -0,0 +1,5 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# MSVC is the default linker +include(Platform/Linker/WindowsCE-MSVC-CXX) diff --git a/Modules/Platform/Linker/WindowsCE-MSVC-C.cmake b/Modules/Platform/Linker/WindowsCE-MSVC-C.cmake new file mode 100644 index 000000000..297a160f5 --- /dev/null +++ b/Modules/Platform/Linker/WindowsCE-MSVC-C.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-MSVC-C) diff --git a/Modules/Platform/Linker/WindowsCE-MSVC-CXX.cmake b/Modules/Platform/Linker/WindowsCE-MSVC-CXX.cmake new file mode 100644 index 000000000..7accb62cb --- /dev/null +++ b/Modules/Platform/Linker/WindowsCE-MSVC-CXX.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-MSVC-CXX) diff --git a/Modules/Platform/Linker/WindowsKernelModeDriver-C.cmake b/Modules/Platform/Linker/WindowsKernelModeDriver-C.cmake new file mode 100644 index 000000000..7d6f303a6 --- /dev/null +++ b/Modules/Platform/Linker/WindowsKernelModeDriver-C.cmake @@ -0,0 +1,5 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# MSVC is the default linker +include(Platform/Linker/WindowsKernelModeDriver-MSVC-C) diff --git a/Modules/Platform/Linker/WindowsKernelModeDriver-CXX.cmake b/Modules/Platform/Linker/WindowsKernelModeDriver-CXX.cmake new file mode 100644 index 000000000..ad69d95b2 --- /dev/null +++ b/Modules/Platform/Linker/WindowsKernelModeDriver-CXX.cmake @@ -0,0 +1,5 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# MSVC is the default linker +include(Platform/Linker/WindowsKernelModeDriver-MSVC-CXX) diff --git a/Modules/Platform/Linker/WindowsKernelModeDriver-MSVC-C.cmake b/Modules/Platform/Linker/WindowsKernelModeDriver-MSVC-C.cmake new file mode 100644 index 000000000..297a160f5 --- /dev/null +++ b/Modules/Platform/Linker/WindowsKernelModeDriver-MSVC-C.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-MSVC-C) diff --git a/Modules/Platform/Linker/WindowsKernelModeDriver-MSVC-CXX.cmake b/Modules/Platform/Linker/WindowsKernelModeDriver-MSVC-CXX.cmake new file mode 100644 index 000000000..7accb62cb --- /dev/null +++ b/Modules/Platform/Linker/WindowsKernelModeDriver-MSVC-CXX.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-MSVC-CXX) diff --git a/Modules/Platform/Linker/WindowsPhone-ASM.cmake b/Modules/Platform/Linker/WindowsPhone-ASM.cmake new file mode 100644 index 000000000..39b77f5cd --- /dev/null +++ b/Modules/Platform/Linker/WindowsPhone-ASM.cmake @@ -0,0 +1,15 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +block(SCOPE_FOR POLICIES) +cmake_policy(SET CMP0054 NEW) + +if(CMAKE_ASM_SIMULATE_ID STREQUAL "MSVC") + # MSVC is the default linker + include(Platform/Linker/WindowsPhone-MSVC-ASM) +else() + # GNU is the default linker + include(Platform/Linker/WindowsPhone-GNU-ASM) +endif() + +endblock() diff --git a/Modules/Platform/Linker/WindowsPhone-C.cmake b/Modules/Platform/Linker/WindowsPhone-C.cmake new file mode 100644 index 000000000..021310c46 --- /dev/null +++ b/Modules/Platform/Linker/WindowsPhone-C.cmake @@ -0,0 +1,15 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +block(SCOPE_FOR POLICIES) +cmake_policy(SET CMP0054 NEW) + +if(CMAKE_C_SIMULATE_ID STREQUAL "MSVC") + # MSVC is the default linker + include(Platform/Linker/WindowsPhone-MSVC-C) +else() + # GNU is the default linker + include(Platform/Linker/WindowsPhone-GNU-C) +endif() + +endblock() diff --git a/Modules/Platform/Linker/WindowsPhone-CXX.cmake b/Modules/Platform/Linker/WindowsPhone-CXX.cmake new file mode 100644 index 000000000..a42075f08 --- /dev/null +++ b/Modules/Platform/Linker/WindowsPhone-CXX.cmake @@ -0,0 +1,15 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +block(SCOPE_FOR POLICIES) +cmake_policy(SET CMP0054 NEW) + +if(CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") + # MSVC is the default linker + include(Platform/Linker/WindowsPhone-MSVC-CXX) +else() + # GNU is the default linker + include(Platform/Linker/WindowsPhone-GNU-CXX) +endif() + +endblock() diff --git a/Modules/Platform/Linker/WindowsPhone-GNU-ASM.cmake b/Modules/Platform/Linker/WindowsPhone-GNU-ASM.cmake new file mode 100644 index 000000000..ec93c6b3f --- /dev/null +++ b/Modules/Platform/Linker/WindowsPhone-GNU-ASM.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-GNU-ASM) diff --git a/Modules/Platform/Linker/WindowsPhone-GNU-C.cmake b/Modules/Platform/Linker/WindowsPhone-GNU-C.cmake new file mode 100644 index 000000000..7a023b8c1 --- /dev/null +++ b/Modules/Platform/Linker/WindowsPhone-GNU-C.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-GNU-C) diff --git a/Modules/Platform/Linker/WindowsPhone-GNU-CXX.cmake b/Modules/Platform/Linker/WindowsPhone-GNU-CXX.cmake new file mode 100644 index 000000000..2a71ff62c --- /dev/null +++ b/Modules/Platform/Linker/WindowsPhone-GNU-CXX.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-GNU-CXX) diff --git a/Modules/Platform/Linker/WindowsPhone-LLD-ASM.cmake b/Modules/Platform/Linker/WindowsPhone-LLD-ASM.cmake new file mode 100644 index 000000000..71db4da75 --- /dev/null +++ b/Modules/Platform/Linker/WindowsPhone-LLD-ASM.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-LLD-ASM) diff --git a/Modules/Platform/Linker/WindowsPhone-LLD-C.cmake b/Modules/Platform/Linker/WindowsPhone-LLD-C.cmake new file mode 100644 index 000000000..8b1415f6f --- /dev/null +++ b/Modules/Platform/Linker/WindowsPhone-LLD-C.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-LLD-C) diff --git a/Modules/Platform/Linker/WindowsPhone-LLD-CXX.cmake b/Modules/Platform/Linker/WindowsPhone-LLD-CXX.cmake new file mode 100644 index 000000000..fc6c9ea1c --- /dev/null +++ b/Modules/Platform/Linker/WindowsPhone-LLD-CXX.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-LLD-CXX) diff --git a/Modules/Platform/Linker/WindowsPhone-MSVC-ASM.cmake b/Modules/Platform/Linker/WindowsPhone-MSVC-ASM.cmake new file mode 100644 index 000000000..a891d7c1f --- /dev/null +++ b/Modules/Platform/Linker/WindowsPhone-MSVC-ASM.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-MSVC-ASM) diff --git a/Modules/Platform/Linker/WindowsPhone-MSVC-C.cmake b/Modules/Platform/Linker/WindowsPhone-MSVC-C.cmake new file mode 100644 index 000000000..297a160f5 --- /dev/null +++ b/Modules/Platform/Linker/WindowsPhone-MSVC-C.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-MSVC-C) diff --git a/Modules/Platform/Linker/WindowsPhone-MSVC-CXX.cmake b/Modules/Platform/Linker/WindowsPhone-MSVC-CXX.cmake new file mode 100644 index 000000000..7accb62cb --- /dev/null +++ b/Modules/Platform/Linker/WindowsPhone-MSVC-CXX.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-MSVC-CXX) diff --git a/Modules/Platform/Linker/WindowsStore-ASM.cmake b/Modules/Platform/Linker/WindowsStore-ASM.cmake new file mode 100644 index 000000000..1d753f3ea --- /dev/null +++ b/Modules/Platform/Linker/WindowsStore-ASM.cmake @@ -0,0 +1,15 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +block(SCOPE_FOR POLICIES) +cmake_policy(SET CMP0054 NEW) + +if(CMAKE_ASM_SIMULATE_ID STREQUAL "MSVC") + # MSVC is the default linker + include(Platform/Linker/WindowsStore-MSVC-ASM) +else() + # GNU is the default linker + include(Platform/Linker/WindowsStore-GNU-ASM) +endif() + +endblock() diff --git a/Modules/Platform/Linker/WindowsStore-C.cmake b/Modules/Platform/Linker/WindowsStore-C.cmake new file mode 100644 index 000000000..cfba4bc35 --- /dev/null +++ b/Modules/Platform/Linker/WindowsStore-C.cmake @@ -0,0 +1,15 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +block(SCOPE_FOR POLICIES) +cmake_policy(SET CMP0054 NEW) + +if(CMAKE_C_SIMULATE_ID STREQUAL "MSVC") + # MSVC is the default linker + include(Platform/Linker/WindowsStore-MSVC-C) +else() + # GNU is the default linker + include(Platform/Linker/WindowsStore-GNU-C) +endif() + +endblock() diff --git a/Modules/Platform/Linker/WindowsStore-CXX.cmake b/Modules/Platform/Linker/WindowsStore-CXX.cmake new file mode 100644 index 000000000..f2a4e29ac --- /dev/null +++ b/Modules/Platform/Linker/WindowsStore-CXX.cmake @@ -0,0 +1,15 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +block(SCOPE_FOR POLICIES) +cmake_policy(SET CMP0054 NEW) + +if(CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") + # MSVC is the default linker + include(Platform/Linker/WindowsStore-MSVC-CXX) +else() + # GNU is the default linker + include(Platform/Linker/WindowsStore-GNU-CXX) +endif() + +endblock() diff --git a/Modules/Platform/Linker/WindowsStore-GNU-ASM.cmake b/Modules/Platform/Linker/WindowsStore-GNU-ASM.cmake new file mode 100644 index 000000000..ec93c6b3f --- /dev/null +++ b/Modules/Platform/Linker/WindowsStore-GNU-ASM.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-GNU-ASM) diff --git a/Modules/Platform/Linker/WindowsStore-GNU-C.cmake b/Modules/Platform/Linker/WindowsStore-GNU-C.cmake new file mode 100644 index 000000000..7a023b8c1 --- /dev/null +++ b/Modules/Platform/Linker/WindowsStore-GNU-C.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-GNU-C) diff --git a/Modules/Platform/Linker/WindowsStore-GNU-CXX.cmake b/Modules/Platform/Linker/WindowsStore-GNU-CXX.cmake new file mode 100644 index 000000000..2a71ff62c --- /dev/null +++ b/Modules/Platform/Linker/WindowsStore-GNU-CXX.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-GNU-CXX) diff --git a/Modules/Platform/Linker/WindowsStore-LLD-ASM.cmake b/Modules/Platform/Linker/WindowsStore-LLD-ASM.cmake new file mode 100644 index 000000000..71db4da75 --- /dev/null +++ b/Modules/Platform/Linker/WindowsStore-LLD-ASM.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-LLD-ASM) diff --git a/Modules/Platform/Linker/WindowsStore-LLD-C.cmake b/Modules/Platform/Linker/WindowsStore-LLD-C.cmake new file mode 100644 index 000000000..8b1415f6f --- /dev/null +++ b/Modules/Platform/Linker/WindowsStore-LLD-C.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-LLD-C) diff --git a/Modules/Platform/Linker/WindowsStore-LLD-CXX.cmake b/Modules/Platform/Linker/WindowsStore-LLD-CXX.cmake new file mode 100644 index 000000000..fc6c9ea1c --- /dev/null +++ b/Modules/Platform/Linker/WindowsStore-LLD-CXX.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-LLD-CXX) diff --git a/Modules/Platform/Linker/WindowsStore-MSVC-ASM.cmake b/Modules/Platform/Linker/WindowsStore-MSVC-ASM.cmake new file mode 100644 index 000000000..a891d7c1f --- /dev/null +++ b/Modules/Platform/Linker/WindowsStore-MSVC-ASM.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-MSVC-ASM) diff --git a/Modules/Platform/Linker/WindowsStore-MSVC-C.cmake b/Modules/Platform/Linker/WindowsStore-MSVC-C.cmake new file mode 100644 index 000000000..297a160f5 --- /dev/null +++ b/Modules/Platform/Linker/WindowsStore-MSVC-C.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-MSVC-C) diff --git a/Modules/Platform/Linker/WindowsStore-MSVC-CXX.cmake b/Modules/Platform/Linker/WindowsStore-MSVC-CXX.cmake new file mode 100644 index 000000000..7accb62cb --- /dev/null +++ b/Modules/Platform/Linker/WindowsStore-MSVC-CXX.cmake @@ -0,0 +1,4 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(Platform/Linker/Windows-MSVC-CXX) diff --git a/Modules/Platform/Linux-Initialize.cmake b/Modules/Platform/Linux-Initialize.cmake index 7166b20e8..e1e5d7ed9 100644 --- a/Modules/Platform/Linux-Initialize.cmake +++ b/Modules/Platform/Linux-Initialize.cmake @@ -2,4 +2,4 @@ set(LINUX 1) set(UNIX 1) # Match multiarch library directory names. -set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_]*") +set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-linux-[a-z0-9_]*") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 9b5b3dc62..27525b7bf 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 31) -set(CMake_VERSION_PATCH 0) +set(CMake_VERSION_PATCH 1) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) @@ -21,7 +21,7 @@ endif() if(NOT CMake_VERSION_NO_GIT) # If this source was exported by 'git archive', use its commit info. - set(git_info [==[e22c8383b9 CMake 3.31.0]==]) + set(git_info [==[eb281d3454 CMake 3.31.1]==]) # Otherwise, try to identify the current development source version. if(NOT git_info MATCHES "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]?[0-9a-f]?)[0-9a-f]* " diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 885094d3e..7311de80c 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -155,6 +155,7 @@ bool cmAddCustomCommandCommand(std::vector const& args, keyPRE_BUILD, keyPRE_LINK, keyTARGET, + keyUSES_TERMINAL, keyVERBATIM, keyWORKING_DIRECTORY }; diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 551a45b88..d445128b6 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -449,6 +449,15 @@ public: "_LINK_LIBRARIES_PROCESSING':\n", errorMessage), target->GetBacktrace()); } + // For some environments, deduplication should be activated only if + // both policies CMP0156 and CMP0179 are NEW + if (makefile->GetDefinition(cmStrCat( + "CMAKE_", linkLanguage, "_PLATFORM_LINKER_ID")) == "LLD"_s && + makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT") == "ELF"_s && + target->GetPolicyStatusCMP0179() != cmPolicies::NEW && + this->Deduplication == All) { + this->Deduplication = Shared; + } } } } diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index 555977c13..e186a08d8 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -18,6 +18,12 @@ #include +#ifndef _WIN32 +# include + +# include "cm_fileno.hxx" +#endif + #include "cmArgumentParser.h" #include "cmExecutionStatus.h" #include "cmList.h" @@ -37,6 +43,20 @@ bool cmExecuteProcessCommandIsWhitespace(char c) return (cmIsSpace(c) || c == '\n' || c == '\r'); } +FILE* FopenCLOEXEC(std::string const& path, const char* mode) +{ + FILE* f = cmsys::SystemTools::Fopen(path, mode); +#ifndef _WIN32 + if (f) { + if (fcntl(cm_fileno(f), F_SETFD, FD_CLOEXEC) < 0) { + fclose(f); + f = nullptr; + } + } +#endif + return f; +} + void cmExecuteProcessCommandFixText(std::vector& output, bool strip_trailing_whitespace); void cmExecuteProcessCommandAppend(std::vector& output, const char* data, @@ -180,7 +200,7 @@ bool cmExecuteProcessCommand(std::vector const& args, // Check the output variables. std::unique_ptr inputFile(nullptr, fclose); if (!inputFilename.empty()) { - inputFile.reset(cmsys::SystemTools::Fopen(inputFilename, "rb")); + inputFile.reset(FopenCLOEXEC(inputFilename, "rb")); if (inputFile) { builder.SetExternalStream(cmUVProcessChainBuilder::Stream_INPUT, inputFile.get()); @@ -191,7 +211,7 @@ bool cmExecuteProcessCommand(std::vector const& args, std::unique_ptr outputFile(nullptr, fclose); if (!outputFilename.empty()) { - outputFile.reset(cmsys::SystemTools::Fopen(outputFilename, "wb")); + outputFile.reset(FopenCLOEXEC(outputFilename, "wb")); if (outputFile) { builder.SetExternalStream(cmUVProcessChainBuilder::Stream_OUTPUT, outputFile.get()); @@ -213,7 +233,7 @@ bool cmExecuteProcessCommand(std::vector const& args, outputFile.get()); } } else { - errorFile.reset(cmsys::SystemTools::Fopen(errorFilename, "wb")); + errorFile.reset(FopenCLOEXEC(errorFilename, "wb")); if (errorFile) { builder.SetExternalStream(cmUVProcessChainBuilder::Stream_ERROR, errorFile.get()); diff --git a/Source/cmExperimental.cxx b/Source/cmExperimental.cxx index 85eff1a87..913db87f5 100644 --- a/Source/cmExperimental.cxx +++ b/Source/cmExperimental.cxx @@ -51,8 +51,8 @@ cmExperimental::FeatureData LookupTable[] = { "b80be207-778e-46ba-8080-b23bba22639e", "CMAKE_EXPERIMENTAL_EXPORT_PACKAGE_INFO", "CMake's support for exporting package information in the Common Package " - "Specification format. It is meant only for experimentation and feedback " - "to CMake developers.", + "Specification format is experimental. It is meant only for " + "experimentation and feedback to CMake developers.", {}, cmExperimental::TryCompileCondition::Always, false }, diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 16aefff64..d3b276956 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -272,9 +272,9 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer, MessageType::DEPRECATION_WARNING, "Compatibility with CMake < 3.10 will be removed from " "a future version of CMake.\n" - "Update the VERSION argument value or use a ... suffix " - "to tell CMake that the project does not need compatibility with " - "older versions."); + "Update the VERSION argument value. Or, use the ... " + "syntax to tell CMake that the project requires at least but has " + "been updated to work with policies introduced by or earlier."); } // now loop over all the policies and set them as appropriate diff --git a/Tests/RunCMake/File_Generate/CMP0070-OLD-stderr.txt b/Tests/RunCMake/File_Generate/CMP0070-OLD-stderr.txt index 185fa5dff..ec215fbd3 100644 --- a/Tests/RunCMake/File_Generate/CMP0070-OLD-stderr.txt +++ b/Tests/RunCMake/File_Generate/CMP0070-OLD-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. + CMake Deprecation Warning at CMP0070-OLD.cmake:[0-9]+ \(cmake_policy\): The OLD behavior for policy CMP0070 will be removed from a future version diff --git a/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt b/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt index 5f8144aff..297483673 100644 --- a/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt +++ b/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. + (CMake Warning \(dev\) in CMakeLists.txt: Policy CMP0070 is not set: Define file\(GENERATE\) behavior for relative diff --git a/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-stderr.txt b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-stderr.txt index 37cc35e45..8479869f7 100644 --- a/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-stderr.txt +++ b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. + CMake Deprecation Warning at SourceProperty-CMP0070-OLD.cmake:[0-9]+ \(cmake_policy\): The OLD behavior for policy CMP0070 will be removed from a future version diff --git a/Tests/RunCMake/GenEx-TARGET_PROPERTY/LOCATION-stderr.txt b/Tests/RunCMake/GenEx-TARGET_PROPERTY/LOCATION-stderr.txt index 79bc554fb..468d2c550 100644 --- a/Tests/RunCMake/GenEx-TARGET_PROPERTY/LOCATION-stderr.txt +++ b/Tests/RunCMake/GenEx-TARGET_PROPERTY/LOCATION-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. + CMake Warning \(dev\) in CMakeLists\.txt: Policy CMP0026 is not set: Disallow use of the LOCATION target property. diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-flush-script-check-list.cmake b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-flush-script-check-list.cmake deleted file mode 100644 index 1ae222fd0..000000000 --- a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-flush-script-check-list.cmake +++ /dev/null @@ -1,5 +0,0 @@ -list(LENGTH flush_script_test_TESTS LIST_SIZE) -set(EXPECTED_LIST_SIZE 4) -if(NOT LIST_SIZE EQUAL ${EXPECTED_LIST_SIZE}) - message("TEST_LIST should have ${EXPECTED_LIST_SIZE} elements but it has ${LIST_SIZE}") -endif() diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-flush-script-check-list.cmake.in b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-flush-script-check-list.cmake.in new file mode 100644 index 000000000..b334d2ba2 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-flush-script-check-list.cmake.in @@ -0,0 +1,34 @@ +set(expected_number_of_tests 12) + +# Check the flushing of the test names buffer +list(LENGTH flush_script_test_TESTS num_test_names) +if(NOT num_test_names EQUAL expected_number_of_tests) + message(FATAL_ERROR + "Test name list has wrong number of test names:\n" + " Expected: ${expected_number_of_tests}\n" + " Actual: ${num_test_names}" + ) +endif() + +# Check the flushing of the script content variable. +# Note that flushing errors would repeat a test name, so such errors are not +# uncovered by checking the name buffer flushing above. + +# PRE_TEST can have a config-specific tests file, POST_BUILD never does +set(tests_file "@CMAKE_CURRENT_BINARY_DIR@/flush_script_test[1]_tests-Debug.cmake") +if(NOT EXISTS "${tests_file}") + set(tests_file "@CMAKE_CURRENT_BINARY_DIR@/flush_script_test[1]_tests.cmake") +endif() +if(NOT EXISTS "${tests_file}") + message(FATAL_ERROR "Tests file is missing") +endif() + +file(STRINGS "${tests_file}" add_test_lines REGEX "^add_test" ENCODING UTF-8) +list(LENGTH add_test_lines num_add_test_lines) +if(NOT num_add_test_lines EQUAL expected_number_of_tests) + message(FATAL_ERROR + "Test script has wrong number of add_test() calls:\n" + " Expected: ${expected_number_of_tests}\n" + " Actual: ${num_add_test_lines}" + ) +endif() diff --git a/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryFlushScript.cmake b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryFlushScript.cmake index 2c138c7b4..b537a5fc9 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryFlushScript.cmake +++ b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryFlushScript.cmake @@ -10,5 +10,11 @@ xcode_sign_adhoc(flush_script_test) gtest_discover_tests( flush_script_test ) + +configure_file(GoogleTest-discovery-flush-script-check-list.cmake.in + check-test-lists.cmake + @ONLY +) set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/GoogleTest-discovery-flush-script-check-list.cmake) + ${CMAKE_CURRENT_BINARY_DIR}/check-test-lists.cmake +) diff --git a/Tests/RunCMake/GoogleTest/flush_script_test.cpp b/Tests/RunCMake/GoogleTest/flush_script_test.cpp index 9473bb5de..f032dda0a 100644 --- a/Tests/RunCMake/GoogleTest/flush_script_test.cpp +++ b/Tests/RunCMake/GoogleTest/flush_script_test.cpp @@ -10,10 +10,11 @@ int main(int argc, char** argv) if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests") { std::cout << "flush_script_test.\n"; const size_t flushThreshold = 50000; - const size_t testCaseNum = 4; - std::string testName(flushThreshold / (testCaseNum - 1), 'T'); - for (size_t i = 0; i < testCaseNum; ++i) - std::cout << " " << testName.c_str() << "\n"; + const size_t flushAfter = 4; + const size_t testCaseNum = 3 * flushAfter; + std::string testName(flushThreshold / flushAfter, 'T'); + for (size_t i = 1; i <= testCaseNum; ++i) + std::cout << " t" << i << testName.c_str() << "\n"; } return 0; } diff --git a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-stderr.txt b/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-stderr.txt index 48e8a016d..a08f80fb9 100644 --- a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-stderr.txt +++ b/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. + CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_minimum_required\): The OLD behavior for policy CMP0052 will be removed from a future version diff --git a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-stderr.txt b/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-stderr.txt index 05c69916d..38acbdd8b 100644 --- a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-stderr.txt +++ b/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. + CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\): The OLD behavior for policy CMP0052 will be removed from a future version diff --git a/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-iface-stderr.txt b/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-iface-stderr.txt index f96567bce..d756db175 100644 --- a/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-iface-stderr.txt +++ b/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-iface-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. + CMake Deprecation Warning at CMP0028-OLD-iface\.cmake:[0-9]+ \(cmake_policy\): The OLD behavior for policy CMP0028 will be removed from a future version diff --git a/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-stderr.txt b/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-stderr.txt index 91a0ad712..8ebf9497b 100644 --- a/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-stderr.txt +++ b/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. + CMake Deprecation Warning at CMP0028-OLD\.cmake:[0-9]+ \(cmake_policy\): The OLD behavior for policy CMP0028 will be removed from a future version diff --git a/Tests/RunCMake/LinkLibrariesStrategy/Inspect.cmake b/Tests/RunCMake/LinkLibrariesStrategy/Inspect.cmake index fd5da9142..26f63882e 100644 --- a/Tests/RunCMake/LinkLibrariesStrategy/Inspect.cmake +++ b/Tests/RunCMake/LinkLibrariesStrategy/Inspect.cmake @@ -3,6 +3,8 @@ enable_language(C) set(info "") foreach(var CMAKE_C_LINK_LIBRARIES_PROCESSING + CMAKE_C_PLATFORM_LINKER_ID + CMAKE_EXECUTABLE_FORMAT ) if(DEFINED ${var}) string(APPEND info "set(${var} \"${${var}}\")\n") diff --git a/Tests/RunCMake/LinkLibrariesStrategy/RunCMakeTest.cmake b/Tests/RunCMake/LinkLibrariesStrategy/RunCMakeTest.cmake index 787b63632..7ae10063a 100644 --- a/Tests/RunCMake/LinkLibrariesStrategy/RunCMakeTest.cmake +++ b/Tests/RunCMake/LinkLibrariesStrategy/RunCMakeTest.cmake @@ -10,13 +10,15 @@ endif() # Detect information from the toolchain: # - CMAKE_C_LINK_LIBRARIES_PROCESSING +# - CMAKE_C_PLATFORM_LINKER_ID +# - CMAKE_EXECUTABLE_FORMAT run_cmake(Inspect) include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") run_cmake(Unknown) function(run_strategy case exe) - foreach(cmp0179 OLD NEW) + foreach(cmp0179 ${cmp0179_states}) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-CMP0179-${cmp0179}-build) set(RunCMake_TEST_VARIANT_DESCRIPTION "...CMP0179-${cmp0179}") if("DEDUPLICATION=ALL" IN_LIST CMAKE_C_LINK_LIBRARIES_PROCESSING) @@ -44,6 +46,13 @@ function(run_strategy case exe) endforeach() endfunction() +if(CMAKE_C_PLATFORM_LINKER_ID STREQUAL "LLD" AND CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF") + # deduplication done only if both CMP0156 and CMP0179 ARE NEW + set(cmp0179_states NEW) +else() + set(cmp0179_states OLD NEW) +endif() + run_strategy(Basic-REORDER_MINIMALLY "main") run_strategy(Basic-REORDER_FREELY "main") diff --git a/Tests/RunCMake/Ninja/CMP0058-OLD-by-stderr.txt b/Tests/RunCMake/Ninja/CMP0058-OLD-by-stderr.txt index 1daf1149a..4cf1f19ff 100644 --- a/Tests/RunCMake/Ninja/CMP0058-OLD-by-stderr.txt +++ b/Tests/RunCMake/Ninja/CMP0058-OLD-by-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. Call Stack \(most recent call first\): CMakeLists.txt:[0-9] \(include\) + diff --git a/Tests/RunCMake/Ninja/CMP0058-OLD-no-stderr.txt b/Tests/RunCMake/Ninja/CMP0058-OLD-no-stderr.txt index bc864beb8..6a9bc6210 100644 --- a/Tests/RunCMake/Ninja/CMP0058-OLD-no-stderr.txt +++ b/Tests/RunCMake/Ninja/CMP0058-OLD-no-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. Call Stack \(most recent call first\): CMakeLists.txt:[0-9] \(include\) + diff --git a/Tests/RunCMake/Ninja/CMP0058-WARN-by-stderr.txt b/Tests/RunCMake/Ninja/CMP0058-WARN-by-stderr.txt index ecf461648..5abfda733 100644 --- a/Tests/RunCMake/Ninja/CMP0058-WARN-by-stderr.txt +++ b/Tests/RunCMake/Ninja/CMP0058-WARN-by-stderr.txt @@ -2,7 +2,8 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. Call Stack \(most recent call first\): CMakeLists.txt:[0-9] \(include\)$ diff --git a/Tests/RunCMake/Ninja/CMP0058-WARN-no-stderr.txt b/Tests/RunCMake/Ninja/CMP0058-WARN-no-stderr.txt index b5d5b0b6e..70d94517f 100644 --- a/Tests/RunCMake/Ninja/CMP0058-WARN-no-stderr.txt +++ b/Tests/RunCMake/Ninja/CMP0058-WARN-no-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. Call Stack \(most recent call first\): CMakeLists.txt:[0-9] \(include\) + diff --git a/Tests/RunCMake/PackageInfo/ExperimentalWarning-stderr.txt b/Tests/RunCMake/PackageInfo/ExperimentalWarning-stderr.txt index 960d54114..05fe1a8ef 100644 --- a/Tests/RunCMake/PackageInfo/ExperimentalWarning-stderr.txt +++ b/Tests/RunCMake/PackageInfo/ExperimentalWarning-stderr.txt @@ -1,7 +1,7 @@ CMake Warning \(dev\) at ExperimentalWarning.cmake:8 \(install\): CMake's support for exporting package information in the Common Package - Specification format. It is meant only for experimentation and feedback to - CMake developers. + Specification format is experimental\. It is meant only for experimentation + and feedback to CMake developers\. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index bf124ddcc..6251ca0da 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -227,8 +227,9 @@ function(run_cmake test) Compatibility with CMake < 3\.10 will be removed from a future version of CMake. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. + ]] "" actual_stderr "${actual_stderr}") endif() diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-OLD-stderr.txt b/Tests/RunCMake/VisibilityPreset/CMP0063-OLD-stderr.txt index 2c04fa090..7837d23df 100644 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-OLD-stderr.txt +++ b/Tests/RunCMake/VisibilityPreset/CMP0063-OLD-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. + CMake Deprecation Warning at CMP0063-OLD.cmake:[0-9]+ \(cmake_policy\): The OLD behavior for policy CMP0063 will be removed from a future version diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe-stderr.txt b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe-stderr.txt index a8e610eaf..dc45d508d 100644 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe-stderr.txt +++ b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. + CMake Warning \(dev\) at CMP0063-WARN-exe.cmake:[0-9]+ \(add_executable\): Policy CMP0063 is not set: Honor visibility properties for all target diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-no-stderr.txt b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-no-stderr.txt index 6f8719ec2..c59fe7bac 100644 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-no-stderr.txt +++ b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-no-stderr.txt @@ -2,5 +2,6 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\.$ + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\.$ diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj-stderr.txt b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj-stderr.txt index 150eebbd5..96bd79275 100644 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj-stderr.txt +++ b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. + CMake Warning \(dev\) at CMP0063-WARN-obj.cmake:[0-9]+ \(add_library\): Policy CMP0063 is not set: Honor visibility properties for all target diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta-stderr.txt b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta-stderr.txt index 3ea8864ef..b945e309e 100644 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta-stderr.txt +++ b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. + CMake Warning \(dev\) at CMP0063-WARN-sta.cmake:[0-9]+ \(add_library\): Policy CMP0063 is not set: Honor visibility properties for all target diff --git a/Tests/RunCMake/add_custom_command/CMP0175-NEW-stderr.txt b/Tests/RunCMake/add_custom_command/CMP0175-NEW-stderr.txt index c3569713e..8b02f7c18 100644 --- a/Tests/RunCMake/add_custom_command/CMP0175-NEW-stderr.txt +++ b/Tests/RunCMake/add_custom_command/CMP0175-NEW-stderr.txt @@ -9,7 +9,7 @@ Call Stack \(most recent call first\): CMake Error at CMP0175\.cmake:[0-9]+ \(add_custom_command\): The following keywords are not supported when using - add_custom_command\(TARGET\): IMPLICIT_DEPENDS, USES_TERMINAL + add_custom_command\(TARGET\): IMPLICIT_DEPENDS Call Stack \(most recent call first\): CMP0175-NEW\.cmake:2 \(include\) CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/add_custom_command/CMP0175-WARN-stderr.txt b/Tests/RunCMake/add_custom_command/CMP0175-WARN-stderr.txt index f49dd7344..23b989e00 100644 --- a/Tests/RunCMake/add_custom_command/CMP0175-WARN-stderr.txt +++ b/Tests/RunCMake/add_custom_command/CMP0175-WARN-stderr.txt @@ -13,7 +13,7 @@ This warning is for project developers\. Use -Wno-dev to suppress it\. CMake Warning \(dev\) at CMP0175\.cmake:[0-9]+ \(add_custom_command\): The following keywords are not supported when using - add_custom_command\(TARGET\): IMPLICIT_DEPENDS, USES_TERMINAL\. + add_custom_command\(TARGET\): IMPLICIT_DEPENDS\. Policy CMP0175 is not set: add_custom_command\(\) rejects invalid arguments\. Run "cmake --help-policy CMP0175" for policy details\. Use the cmake_policy diff --git a/Tests/RunCMake/add_custom_command/CMP0175.cmake b/Tests/RunCMake/add_custom_command/CMP0175.cmake index 0c20f4e3b..fa877e794 100644 --- a/Tests/RunCMake/add_custom_command/CMP0175.cmake +++ b/Tests/RunCMake/add_custom_command/CMP0175.cmake @@ -24,14 +24,15 @@ add_custom_command(TARGET main #OUTPUT # Other checks will fail before the CMP0175 check #OUTPUTS # Special case, not a documented keyword (used for deprecated form) #SOURCE # Old signature, special handling makes it hard to check - #USES_TERMINAL ) add_custom_command(TARGET main POST_BUILD COMMAND ${CMAKE_COMMAND} -E true # Has to be tested separately due to separate check for clash with DEPFILE IMPLICIT_DEPENDS valueDoesNotMatterHere - # Has to be tested separately due to separate check for clash with JOB_POOL + # Has to be tested separately due to separate check for clash with JOB_POOL. + # This one is supported, but was erroneously rejected in the 3.31.0 release. + # We keep this here to verify the fix for that regression. USES_TERMINAL NO ) diff --git a/Tests/RunCMake/cmake_minimum_required/Before3_10-stderr.txt b/Tests/RunCMake/cmake_minimum_required/Before3_10-stderr.txt index 570968425..4a6842bea 100644 --- a/Tests/RunCMake/cmake_minimum_required/Before3_10-stderr.txt +++ b/Tests/RunCMake/cmake_minimum_required/Before3_10-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + @@ -11,8 +12,9 @@ CMake Deprecation Warning at Before3_10\.cmake:2 \(cmake_policy\): Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + @@ -20,7 +22,8 @@ CMake Deprecation Warning at Before3_10\.cmake:6 \(cmake_policy\): Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_minimum_required/CompatBefore24-stderr.txt b/Tests/RunCMake/cmake_minimum_required/CompatBefore24-stderr.txt index 816cdacba..1363d0922 100644 --- a/Tests/RunCMake/cmake_minimum_required/CompatBefore24-stderr.txt +++ b/Tests/RunCMake/cmake_minimum_required/CompatBefore24-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + diff --git a/Tests/RunCMake/ctest_build/BuildFailure-CMP0061-OLD-stderr.txt b/Tests/RunCMake/ctest_build/BuildFailure-CMP0061-OLD-stderr.txt index 9a6217401..18710a30b 100644 --- a/Tests/RunCMake/ctest_build/BuildFailure-CMP0061-OLD-stderr.txt +++ b/Tests/RunCMake/ctest_build/BuildFailure-CMP0061-OLD-stderr.txt @@ -3,7 +3,8 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. +(Error\(s\) when building project )?ctest_build returned zero$ diff --git a/Tests/RunCMake/include/CMP0024-WARN-stderr.txt b/Tests/RunCMake/include/CMP0024-WARN-stderr.txt index 6cf4a7b69..5e9f1d732 100644 --- a/Tests/RunCMake/include/CMP0024-WARN-stderr.txt +++ b/Tests/RunCMake/include/CMP0024-WARN-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\) + diff --git a/Tests/RunCMake/install/CMP0062-OLD-stderr.txt b/Tests/RunCMake/install/CMP0062-OLD-stderr.txt index 8eeef6548..0a2981e94 100644 --- a/Tests/RunCMake/install/CMP0062-OLD-stderr.txt +++ b/Tests/RunCMake/install/CMP0062-OLD-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. Call Stack \(most recent call first\): CMakeLists.txt:[0-9]+ \(include\) + diff --git a/Tests/RunCMake/list/GET-CMP0007-WARN-stderr.txt b/Tests/RunCMake/list/GET-CMP0007-WARN-stderr.txt index 745329040..4f376d8e8 100644 --- a/Tests/RunCMake/list/GET-CMP0007-WARN-stderr.txt +++ b/Tests/RunCMake/list/GET-CMP0007-WARN-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + diff --git a/Tests/RunCMake/project/CMP0048-NEW-stderr.txt b/Tests/RunCMake/project/CMP0048-NEW-stderr.txt index dde1afca4..b6c6b1fdf 100644 --- a/Tests/RunCMake/project/CMP0048-NEW-stderr.txt +++ b/Tests/RunCMake/project/CMP0048-NEW-stderr.txt @@ -2,5 +2,6 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\.$ + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\.$ diff --git a/Tests/RunCMake/project/CMP0048-OLD-stderr.txt b/Tests/RunCMake/project/CMP0048-OLD-stderr.txt index 1fb207fac..51e43f095 100644 --- a/Tests/RunCMake/project/CMP0048-OLD-stderr.txt +++ b/Tests/RunCMake/project/CMP0048-OLD-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. + CMake Deprecation Warning at CMP0048-OLD\.cmake:1 \(cmake_policy\): The OLD behavior for policy CMP0048 will be removed from a future version diff --git a/Tests/RunCMake/project_injected/CMP0048-WARN-stderr.txt b/Tests/RunCMake/project_injected/CMP0048-WARN-stderr.txt index cb5d87449..38ec91fa4 100644 --- a/Tests/RunCMake/project_injected/CMP0048-WARN-stderr.txt +++ b/Tests/RunCMake/project_injected/CMP0048-WARN-stderr.txt @@ -15,5 +15,6 @@ CMake Deprecation Warning at CMakeLists\.txt:1 \(cmake_minimum_required\): Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\.$ + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\.$ diff --git a/Tests/RunCMake/try_compile/CMP0066-stderr.txt b/Tests/RunCMake/try_compile/CMP0066-stderr.txt index 0b621f0f7..ef1e53182 100644 --- a/Tests/RunCMake/try_compile/CMP0066-stderr.txt +++ b/Tests/RunCMake/try_compile/CMP0066-stderr.txt @@ -2,8 +2,9 @@ Compatibility with CMake < 3\.10 will be removed from a future version of CMake\. - Update the VERSION argument value or use a \.\.\. suffix to tell - CMake that the project does not need compatibility with older versions\. + Update the VERSION argument value\. Or, use the \.\.\. syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier\. + before try_compile with CMP0066 WARN-default after try_compile with CMP0066 WARN-default diff --git a/Utilities/Scripts/update-libarchive.bash b/Utilities/Scripts/update-libarchive.bash index 19c2d3211..ad2a78951 100755 --- a/Utilities/Scripts/update-libarchive.bash +++ b/Utilities/Scripts/update-libarchive.bash @@ -8,7 +8,7 @@ readonly name="LibArchive" readonly ownership="LibArchive Upstream " readonly subtree="Utilities/cmlibarchive" readonly repo="https://github.com/libarchive/libarchive.git" -readonly tag="v3.7.5" +readonly tag="v3.7.7" readonly shortlog=false readonly paths=" CMakeLists.txt diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt index feeaa3b77..4e4b49c1d 100644 --- a/Utilities/cmlibarchive/CMakeLists.txt +++ b/Utilities/cmlibarchive/CMakeLists.txt @@ -908,6 +908,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 diff --git a/Utilities/cmlibarchive/build/version b/Utilities/cmlibarchive/build/version index 49ac2b56a..56b5c9db9 100644 --- a/Utilities/cmlibarchive/build/version +++ b/Utilities/cmlibarchive/build/version @@ -1 +1 @@ -3007005 +3007007 diff --git a/Utilities/cmlibarchive/libarchive/archive.h b/Utilities/cmlibarchive/libarchive/archive.h index c4a06901c..0b2fb2f01 100644 --- a/Utilities/cmlibarchive/libarchive/archive.h +++ b/Utilities/cmlibarchive/libarchive/archive.h @@ -34,7 +34,7 @@ * assert that ARCHIVE_VERSION_NUMBER >= 2012108. */ /* Note: Compiler will complain if this does not match archive_entry.h! */ -#define ARCHIVE_VERSION_NUMBER 3007005 +#define ARCHIVE_VERSION_NUMBER 3007007 #include #include /* for wchar_t */ @@ -152,7 +152,7 @@ __LA_DECL int archive_version_number(void); /* * Textual name/version of the library, useful for version displays. */ -#define ARCHIVE_VERSION_ONLY_STRING "3.7.5" +#define ARCHIVE_VERSION_ONLY_STRING "3.7.7" #define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING __LA_DECL const char * archive_version_string(void); diff --git a/Utilities/cmlibarchive/libarchive/archive_acl.c b/Utilities/cmlibarchive/libarchive/archive_acl.c index 51a088121..2acbad180 100644 --- a/Utilities/cmlibarchive/libarchive/archive_acl.c +++ b/Utilities/cmlibarchive/libarchive/archive_acl.c @@ -60,7 +60,7 @@ static int archive_acl_add_entry_len_l(struct archive_acl *acl, int type, int permset, int tag, int id, const char *name, size_t len, struct archive_string_conv *sc); static int archive_acl_text_want_type(struct archive_acl *acl, int flags); -static ssize_t archive_acl_text_len(struct archive_acl *acl, int want_type, +static size_t archive_acl_text_len(struct archive_acl *acl, int want_type, int flags, int wide, struct archive *a, struct archive_string_conv *sc); static int isint_w(const wchar_t *start, const wchar_t *end, int *result); @@ -350,7 +350,7 @@ acl_new_entry(struct archive_acl *acl, } /* Add a new entry to the end of the list. */ - ap = (struct archive_acl_entry *)calloc(1, sizeof(*ap)); + ap = calloc(1, sizeof(*ap)); if (ap == NULL) return (NULL); if (aq == NULL) @@ -532,14 +532,14 @@ archive_acl_text_want_type(struct archive_acl *acl, int flags) /* * Calculate ACL text string length */ -static ssize_t +static size_t archive_acl_text_len(struct archive_acl *acl, int want_type, int flags, int wide, struct archive *a, struct archive_string_conv *sc) { struct archive_acl_entry *ap; const char *name; const wchar_t *wname; int count, idlen, tmp, r; - ssize_t length; + size_t length; size_t len; count = 0; @@ -668,7 +668,7 @@ archive_acl_to_text_w(struct archive_acl *acl, ssize_t *text_len, int flags, struct archive *a) { int count; - ssize_t length; + size_t length; size_t len; const wchar_t *wname; const wchar_t *prefix; @@ -697,7 +697,7 @@ archive_acl_to_text_w(struct archive_acl *acl, ssize_t *text_len, int flags, separator = L'\n'; /* Now, allocate the string and actually populate it. */ - wp = ws = (wchar_t *)malloc(length * sizeof(wchar_t)); + wp = ws = malloc(length * sizeof(*wp)); if (wp == NULL) { if (errno == ENOMEM) __archive_errx(1, "No memory"); @@ -759,7 +759,7 @@ archive_acl_to_text_w(struct archive_acl *acl, ssize_t *text_len, int flags, len = wcslen(ws); - if ((ssize_t)len > (length - 1)) + if (len > length - 1) __archive_errx(1, "Buffer overrun"); if (text_len != NULL) @@ -901,7 +901,7 @@ archive_acl_to_text_l(struct archive_acl *acl, ssize_t *text_len, int flags, struct archive_string_conv *sc) { int count; - ssize_t length; + size_t length; size_t len; const char *name; const char *prefix; @@ -930,7 +930,7 @@ archive_acl_to_text_l(struct archive_acl *acl, ssize_t *text_len, int flags, separator = '\n'; /* Now, allocate the string and actually populate it. */ - p = s = (char *)malloc(length * sizeof(char)); + p = s = malloc(length * sizeof(*p)); if (p == NULL) { if (errno == ENOMEM) __archive_errx(1, "No memory"); @@ -994,7 +994,7 @@ archive_acl_to_text_l(struct archive_acl *acl, ssize_t *text_len, int flags, len = strlen(s); - if ((ssize_t)len > (length - 1)) + if (len > length - 1) __archive_errx(1, "Buffer overrun"); if (text_len != NULL) diff --git a/Utilities/cmlibarchive/libarchive/archive_cryptor.c b/Utilities/cmlibarchive/libarchive/archive_cryptor.c index 437dba06b..1825af4dc 100644 --- a/Utilities/cmlibarchive/libarchive/archive_cryptor.c +++ b/Utilities/cmlibarchive/libarchive/archive_cryptor.c @@ -57,7 +57,7 @@ pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt, return 0; } -#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) +#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA #ifdef _MSC_VER #pragma comment(lib, "Bcrypt.lib") #endif @@ -197,7 +197,7 @@ aes_ctr_release(archive_crypto_ctx *ctx) return 0; } -#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) +#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA static int aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len) diff --git a/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h b/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h index 16b6d16ff..c13f29260 100644 --- a/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h +++ b/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h @@ -62,7 +62,7 @@ typedef struct { unsigned encr_pos; } archive_crypto_ctx; -#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) +#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA #include /* Common in other bcrypt implementations, but missing from VS2008. */ diff --git a/Utilities/cmlibarchive/libarchive/archive_entry.c b/Utilities/cmlibarchive/libarchive/archive_entry.c index f68fee65d..4ebfc5fa6 100644 --- a/Utilities/cmlibarchive/libarchive/archive_entry.c +++ b/Utilities/cmlibarchive/libarchive/archive_entry.c @@ -263,7 +263,7 @@ archive_entry_new2(struct archive *a) { struct archive_entry *entry; - entry = (struct archive_entry *)calloc(1, sizeof(*entry)); + entry = calloc(1, sizeof(*entry)); if (entry == NULL) return (NULL); entry->archive = a; @@ -2095,7 +2095,7 @@ ae_fflagstostr(unsigned long bitset, unsigned long bitclear) if (length == 0) return (NULL); - string = (char *)malloc(length); + string = malloc(length); if (string == NULL) return (NULL); diff --git a/Utilities/cmlibarchive/libarchive/archive_entry.h b/Utilities/cmlibarchive/libarchive/archive_entry.h index f89bdb9e2..a50786a33 100644 --- a/Utilities/cmlibarchive/libarchive/archive_entry.h +++ b/Utilities/cmlibarchive/libarchive/archive_entry.h @@ -28,7 +28,7 @@ #define ARCHIVE_ENTRY_H_INCLUDED /* Note: Compiler will complain if this does not match archive.h! */ -#define ARCHIVE_VERSION_NUMBER 3007005 +#define ARCHIVE_VERSION_NUMBER 3007007 /* * Note: archive_entry.h is for use outside of libarchive; the diff --git a/Utilities/cmlibarchive/libarchive/archive_entry_sparse.c b/Utilities/cmlibarchive/libarchive/archive_entry_sparse.c index b81684d18..c43089611 100644 --- a/Utilities/cmlibarchive/libarchive/archive_entry_sparse.c +++ b/Utilities/cmlibarchive/libarchive/archive_entry_sparse.c @@ -76,7 +76,7 @@ archive_entry_sparse_add_entry(struct archive_entry *entry, } } - if ((sp = (struct ae_sparse *)malloc(sizeof(*sp))) == NULL) + if ((sp = malloc(sizeof(*sp))) == NULL) /* XXX Error XXX */ return; diff --git a/Utilities/cmlibarchive/libarchive/archive_entry_xattr.c b/Utilities/cmlibarchive/libarchive/archive_entry_xattr.c index 14848a5ab..b92e1878b 100644 --- a/Utilities/cmlibarchive/libarchive/archive_entry_xattr.c +++ b/Utilities/cmlibarchive/libarchive/archive_entry_xattr.c @@ -90,7 +90,7 @@ archive_entry_xattr_add_entry(struct archive_entry *entry, { struct ae_xattr *xp; - if ((xp = (struct ae_xattr *)malloc(sizeof(struct ae_xattr))) == NULL) + if ((xp = malloc(sizeof(struct ae_xattr))) == NULL) __archive_errx(1, "Out of memory"); if ((xp->name = strdup(name)) == NULL) diff --git a/Utilities/cmlibarchive/libarchive/archive_hmac.c b/Utilities/cmlibarchive/libarchive/archive_hmac.c index edb3bf5ab..210cca707 100644 --- a/Utilities/cmlibarchive/libarchive/archive_hmac.c +++ b/Utilities/cmlibarchive/libarchive/archive_hmac.c @@ -74,7 +74,7 @@ __hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx) memset(ctx, 0, sizeof(*ctx)); } -#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) +#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA #ifndef BCRYPT_HASH_REUSABLE_FLAG # define BCRYPT_HASH_REUSABLE_FLAG 0x00000020 diff --git a/Utilities/cmlibarchive/libarchive/archive_hmac_private.h b/Utilities/cmlibarchive/libarchive/archive_hmac_private.h index d0fda7f96..1b24ddd1b 100644 --- a/Utilities/cmlibarchive/libarchive/archive_hmac_private.h +++ b/Utilities/cmlibarchive/libarchive/archive_hmac_private.h @@ -52,7 +52,7 @@ int __libarchive_hmac_build_hack(void); typedef CCHmacContext archive_hmac_sha1_ctx; -#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) +#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA #include typedef struct { diff --git a/Utilities/cmlibarchive/libarchive/archive_match.c b/Utilities/cmlibarchive/libarchive/archive_match.c index b9af18c71..f74de99c7 100644 --- a/Utilities/cmlibarchive/libarchive/archive_match.c +++ b/Utilities/cmlibarchive/libarchive/archive_match.c @@ -220,7 +220,7 @@ archive_match_new(void) { struct archive_match *a; - a = (struct archive_match *)calloc(1, sizeof(*a)); + a = calloc(1, sizeof(*a)); if (a == NULL) return (NULL); a->archive.magic = ARCHIVE_MATCH_MAGIC; diff --git a/Utilities/cmlibarchive/libarchive/archive_openssl_evp_private.h b/Utilities/cmlibarchive/libarchive/archive_openssl_evp_private.h index 8ac477280..d5ba7b0d6 100644 --- a/Utilities/cmlibarchive/libarchive/archive_openssl_evp_private.h +++ b/Utilities/cmlibarchive/libarchive/archive_openssl_evp_private.h @@ -39,7 +39,7 @@ #include /* memset */ static inline EVP_MD_CTX *EVP_MD_CTX_new(void) { - EVP_MD_CTX *ctx = (EVP_MD_CTX *)calloc(1, sizeof(EVP_MD_CTX)); + EVP_MD_CTX *ctx = calloc(1, sizeof(EVP_MD_CTX)); return ctx; } diff --git a/Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h b/Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h index 25c8dda65..8ed76260d 100644 --- a/Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h +++ b/Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h @@ -39,7 +39,7 @@ #include /* memset */ static inline HMAC_CTX *HMAC_CTX_new(void) { - HMAC_CTX *ctx = (HMAC_CTX *)calloc(1, sizeof(HMAC_CTX)); + HMAC_CTX *ctx = calloc(1, sizeof(HMAC_CTX)); return ctx; } diff --git a/Utilities/cmlibarchive/libarchive/archive_ppmd7.c b/Utilities/cmlibarchive/libarchive/archive_ppmd7.c index cc3f77820..30124f174 100644 --- a/Utilities/cmlibarchive/libarchive/archive_ppmd7.c +++ b/Utilities/cmlibarchive/libarchive/archive_ppmd7.c @@ -138,7 +138,7 @@ static Bool Ppmd7_Alloc(CPpmd7 *p, UInt32 size) #else 4 - (size & 3); #endif - if ((p->Base = (Byte *)malloc(p->AlignOffset + size + if ((p->Base = malloc(p->AlignOffset + size #ifndef PPMD_32BIT + UNIT_SIZE #endif diff --git a/Utilities/cmlibarchive/libarchive/archive_ppmd8.c b/Utilities/cmlibarchive/libarchive/archive_ppmd8.c index 627c311d2..a748bb97c 100644 --- a/Utilities/cmlibarchive/libarchive/archive_ppmd8.c +++ b/Utilities/cmlibarchive/libarchive/archive_ppmd8.c @@ -111,7 +111,7 @@ Bool Ppmd8_Alloc(CPpmd8 *p, UInt32 size) #else 4 - (size & 3); #endif - if ((p->Base = (Byte *)malloc(p->AlignOffset + size)) == 0) + if ((p->Base = malloc(p->AlignOffset + size)) == 0) return False; p->Size = size; } diff --git a/Utilities/cmlibarchive/libarchive/archive_private.h b/Utilities/cmlibarchive/libarchive/archive_private.h index 5c5b5607a..050fc63c0 100644 --- a/Utilities/cmlibarchive/libarchive/archive_private.h +++ b/Utilities/cmlibarchive/libarchive/archive_private.h @@ -160,9 +160,9 @@ __LA_NORETURN void __archive_errx(int retvalue, const char *msg); void __archive_ensure_cloexec_flag(int fd); int __archive_mktemp(const char *tmpdir); #if defined(_WIN32) && !defined(__CYGWIN__) -int __archive_mkstemp(wchar_t *template); +int __archive_mkstemp(wchar_t *templates); #else -int __archive_mkstemp(char *template); +int __archive_mkstemp(char *templates); #endif int __archive_clean(struct archive *); diff --git a/Utilities/cmlibarchive/libarchive/archive_read.c b/Utilities/cmlibarchive/libarchive/archive_read.c index 1fa35853c..822c534b8 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read.c +++ b/Utilities/cmlibarchive/libarchive/archive_read.c @@ -92,7 +92,7 @@ archive_read_new(void) { struct archive_read *a; - a = (struct archive_read *)calloc(1, sizeof(*a)); + a = calloc(1, sizeof(*a)); if (a == NULL) return (NULL); a->archive.magic = ARCHIVE_READ_MAGIC; @@ -582,7 +582,7 @@ choose_filters(struct archive_read *a) } filter - = (struct archive_read_filter *)calloc(1, sizeof(*filter)); + = calloc(1, sizeof(*filter)); if (filter == NULL) return (ARCHIVE_FATAL); filter->bidder = best_bidder; @@ -1451,7 +1451,7 @@ __archive_read_filter_ahead(struct archive_read_filter *filter, s = t; } /* Now s >= min, so allocate a new buffer. */ - p = (char *)malloc(s); + p = malloc(s); if (p == NULL) { archive_set_error( &filter->archive->archive, diff --git a/Utilities/cmlibarchive/libarchive/archive_read_append_filter.c b/Utilities/cmlibarchive/libarchive/archive_read_append_filter.c index 59ea5c442..a3986e9b6 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_append_filter.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_append_filter.c @@ -123,8 +123,7 @@ archive_read_append_filter(struct archive *_a, int code) return (ARCHIVE_FATAL); } - filter - = (struct archive_read_filter *)calloc(1, sizeof(*filter)); + filter = calloc(1, sizeof(*filter)); if (filter == NULL) { archive_set_error(&a->archive, ENOMEM, "Out of memory"); @@ -180,8 +179,7 @@ archive_read_append_filter_program_signature(struct archive *_a, return (ARCHIVE_FATAL); } - filter - = (struct archive_read_filter *)calloc(1, sizeof(*filter)); + filter = calloc(1, sizeof(*filter)); if (filter == NULL) { archive_set_error(&a->archive, ENOMEM, "Out of memory"); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c b/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c index eea8259ff..4cf008016 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c @@ -455,7 +455,7 @@ archive_read_disk_new(void) { struct archive_read_disk *a; - a = (struct archive_read_disk *)calloc(1, sizeof(*a)); + a = calloc(1, sizeof(*a)); if (a == NULL) return (NULL); a->archive.magic = ARCHIVE_READ_DISK_MAGIC; diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c b/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c index 285747ea9..cb59b5160 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c @@ -49,6 +49,8 @@ /* Old SDKs do not provide IO_REPARSE_TAG_SYMLINK */ #define IO_REPARSE_TAG_SYMLINK 0xA000000CL #endif +/* To deal with absolute symlink isuues */ +#define START_ABSOLUTE_SYMLINK_REPARSE L"\\??\\" /*- * This is a new directory-walking system that addresses a number @@ -375,7 +377,7 @@ la_linkname_from_handle(HANDLE h, wchar_t **linkname, int *linktype) return (-1); } - tbuf = malloc(len + 1 * sizeof(wchar_t)); + tbuf = malloc(len + sizeof(wchar_t)); if (tbuf == NULL) { free(indata); return (-1); @@ -386,18 +388,21 @@ la_linkname_from_handle(HANDLE h, wchar_t **linkname, int *linktype) free(indata); tbuf[len / sizeof(wchar_t)] = L'\0'; + if (wcsncmp(tbuf, START_ABSOLUTE_SYMLINK_REPARSE, 4) == 0) { + /* Absolute symlink, so we'll change the NT path into a verbatim one */ + tbuf[1] = L'\\'; + } else { + /* Relative symlink, so we can translate backslashes to slashes */ + wchar_t *temp = tbuf; + do { + if (*temp == L'\\') + *temp = L'/'; + temp++; + } while(*temp != L'\0'); + } *linkname = tbuf; - /* - * Translate backslashes to slashes for libarchive internal use - */ - while(*tbuf != L'\0') { - if (*tbuf == L'\\') - *tbuf = L'/'; - tbuf++; - } - if ((st.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) *linktype = AE_SYMLINK_TYPE_FILE; else @@ -538,7 +543,7 @@ archive_read_disk_new(void) { struct archive_read_disk *a; - a = (struct archive_read_disk *)calloc(1, sizeof(*a)); + a = calloc(1, sizeof(*a)); if (a == NULL) return (NULL); a->archive.magic = ARCHIVE_READ_DISK_MAGIC; @@ -2473,7 +2478,7 @@ setup_sparse_from_disk(struct archive_read_disk *a, range.FileOffset.QuadPart = 0; range.Length.QuadPart = entry_size; outranges_size = 2048; - outranges = (FILE_ALLOCATED_RANGE_BUFFER *)malloc(outranges_size); + outranges = malloc(outranges_size); if (outranges == NULL) { archive_set_error(&a->archive, ENOMEM, "Couldn't allocate memory"); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_extract2.c b/Utilities/cmlibarchive/libarchive/archive_read_extract2.c index e11cac159..7cf38c301 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_extract2.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_extract2.c @@ -51,7 +51,7 @@ struct archive_read_extract * __archive_read_get_extract(struct archive_read *a) { if (a->extract == NULL) { - a->extract = (struct archive_read_extract *)calloc(1, sizeof(*a->extract)); + a->extract = calloc(1, sizeof(*a->extract)); if (a->extract == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't extract"); return (NULL); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_open_fd.c b/Utilities/cmlibarchive/libarchive/archive_read_open_fd.c index 3ee2423d3..debfde208 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_open_fd.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_open_fd.c @@ -74,7 +74,7 @@ archive_read_open_fd(struct archive *a, int fd, size_t block_size) return (ARCHIVE_FATAL); } - mine = (struct read_fd_data *)calloc(1, sizeof(*mine)); + mine = calloc(1, sizeof(*mine)); b = malloc(block_size); if (mine == NULL || b == NULL) { archive_set_error(a, ENOMEM, "No memory"); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_open_file.c b/Utilities/cmlibarchive/libarchive/archive_read_open_file.c index dcf1d4698..cf49ebd8f 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_open_file.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_open_file.c @@ -69,7 +69,7 @@ archive_read_open_FILE(struct archive *a, FILE *f) void *b; archive_clear_error(a); - mine = (struct read_FILE_data *)malloc(sizeof(*mine)); + mine = malloc(sizeof(*mine)); b = malloc(block_size); if (mine == NULL || b == NULL) { archive_set_error(a, ENOMEM, "No memory"); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_open_filename.c b/Utilities/cmlibarchive/libarchive/archive_read_open_filename.c index dd2e16022..8def020ff 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_open_filename.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_open_filename.c @@ -122,7 +122,7 @@ archive_read_open_filenames(struct archive *a, const char **filenames, { if (filename == NULL) filename = ""; - mine = (struct read_file_data *)calloc(1, + mine = calloc(1, sizeof(*mine) + strlen(filename)); if (mine == NULL) goto no_memory; @@ -175,7 +175,7 @@ archive_read_open_filenames_w(struct archive *a, const wchar_t **wfilenames, { if (wfilename == NULL) wfilename = L""; - mine = (struct read_file_data *)calloc(1, + mine = calloc(1, sizeof(*mine) + wcslen(wfilename) * sizeof(wchar_t)); if (mine == NULL) goto no_memory; diff --git a/Utilities/cmlibarchive/libarchive/archive_read_open_memory.c b/Utilities/cmlibarchive/libarchive/archive_read_open_memory.c index a057ce643..460bb5ae6 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_open_memory.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_open_memory.c @@ -69,7 +69,7 @@ archive_read_open_memory2(struct archive *a, const void *buff, { struct read_memory_data *mine; - mine = (struct read_memory_data *)calloc(1, sizeof(*mine)); + mine = calloc(1, sizeof(*mine)); if (mine == NULL) { archive_set_error(a, ENOMEM, "No memory"); return (ARCHIVE_FATAL); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_bzip2.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_bzip2.c index a118a0374..a7fb44f5b 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_bzip2.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_bzip2.c @@ -190,8 +190,8 @@ bzip2_reader_init(struct archive_read_filter *self) self->code = ARCHIVE_FILTER_BZIP2; self->name = "bzip2"; - state = (struct private_data *)calloc(1, sizeof(*state)); - out_block = (unsigned char *)malloc(out_block_size); + state = calloc(1, sizeof(*state)); + out_block = malloc(out_block_size); if (state == NULL || out_block == NULL) { archive_set_error(&self->archive->archive, ENOMEM, "Can't allocate data for bzip2 decompression"); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_compress.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_compress.c index 29ae72abe..b6e9816df 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_compress.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_compress.c @@ -217,7 +217,7 @@ compress_bidder_init(struct archive_read_filter *self) self->code = ARCHIVE_FILTER_COMPRESS; self->name = "compress (.Z)"; - state = (struct private_data *)calloc(1, sizeof(*state)); + state = calloc(1, sizeof(*state)); out_block = malloc(out_block_size); if (state == NULL || out_block == NULL) { free(out_block); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_gzip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_gzip.c index d24386090..728d846d1 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_gzip.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_gzip.c @@ -123,6 +123,8 @@ archive_read_support_filter_gzip(struct archive *_a) * number of bytes in header. If pbits is non-NULL, it receives a * count of bits verified, suitable for use by bidder. */ +#define MAX_FILENAME_LENGTH (1024 * 1024L) +#define MAX_COMMENT_LENGTH (1024 * 1024L) static ssize_t peek_at_header(struct archive_read_filter *filter, int *pbits, #ifdef HAVE_ZLIB_H @@ -180,9 +182,13 @@ peek_at_header(struct archive_read_filter *filter, int *pbits, #endif do { ++len; - if (avail < len) + if (avail < len) { + if (avail > MAX_FILENAME_LENGTH) { + return (0); + } p = __archive_read_filter_ahead(filter, len, &avail); + } if (p == NULL) return (0); } while (p[len - 1] != 0); @@ -200,9 +206,13 @@ peek_at_header(struct archive_read_filter *filter, int *pbits, if (header_flags & 16) { do { ++len; - if (avail < len) + if (avail < len) { + if (avail > MAX_COMMENT_LENGTH) { + return (0); + } p = __archive_read_filter_ahead(filter, len, &avail); + } if (p == NULL) return (0); } while (p[len - 1] != 0); @@ -307,8 +317,8 @@ gzip_bidder_init(struct archive_read_filter *self) self->code = ARCHIVE_FILTER_GZIP; self->name = "gzip"; - state = (struct private_data *)calloc(1, sizeof(*state)); - out_block = (unsigned char *)malloc(out_block_size); + state = calloc(1, sizeof(*state)); + out_block = malloc(out_block_size); if (state == NULL || out_block == NULL) { free(out_block); free(state); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lz4.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lz4.c index bccf4fb8f..8c9777156 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lz4.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lz4.c @@ -223,7 +223,7 @@ lz4_reader_init(struct archive_read_filter *self) self->code = ARCHIVE_FILTER_LZ4; self->name = "lz4"; - state = (struct private_data *)calloc(1, sizeof(*state)); + state = calloc(1, sizeof(*state)); if (state == NULL) { archive_set_error(&self->archive->archive, ENOMEM, "Can't allocate data for lz4 decompression"); @@ -248,7 +248,7 @@ lz4_allocate_out_block(struct archive_read_filter *self) out_block_size += 64 * 1024; if (state->out_block_size < out_block_size) { free(state->out_block); - out_block = (unsigned char *)malloc(out_block_size); + out_block = malloc(out_block_size); state->out_block_size = out_block_size; if (out_block == NULL) { archive_set_error(&self->archive->archive, ENOMEM, @@ -271,7 +271,7 @@ lz4_allocate_out_block_for_legacy(struct archive_read_filter *self) if (state->out_block_size < out_block_size) { free(state->out_block); - out_block = (unsigned char *)malloc(out_block_size); + out_block = malloc(out_block_size); state->out_block_size = out_block_size; if (out_block == NULL) { archive_set_error(&self->archive->archive, ENOMEM, diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lzop.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lzop.c index 0eec7164d..2fe8bd8d7 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lzop.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lzop.c @@ -185,7 +185,7 @@ lzop_bidder_init(struct archive_read_filter *self) self->code = ARCHIVE_FILTER_LZOP; self->name = "lzop"; - state = (struct read_lzop *)calloc(1, sizeof(*state)); + state = calloc(1, sizeof(*state)); if (state == NULL) { archive_set_error(&self->archive->archive, ENOMEM, "Can't allocate data for lzop decompression"); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_program.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_program.c index 0482c57c1..9e825223b 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_program.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_program.c @@ -139,7 +139,7 @@ archive_read_support_filter_program_signature(struct archive *_a, /* * Allocate our private state. */ - state = (struct program_bidder *)calloc(1, sizeof (*state)); + state = calloc(1, sizeof (*state)); if (state == NULL) goto memerr; state->cmd = strdup(cmd); @@ -398,8 +398,8 @@ __archive_read_program(struct archive_read_filter *self, const char *cmd) size_t l; l = strlen(prefix) + strlen(cmd) + 1; - state = (struct program_filter *)calloc(1, sizeof(*state)); - out_buf = (char *)malloc(out_buf_len); + state = calloc(1, sizeof(*state)); + out_buf = malloc(out_buf_len); if (state == NULL || out_buf == NULL || archive_string_ensure(&state->description, l) == NULL) { archive_set_error(&self->archive->archive, ENOMEM, diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_rpm.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_rpm.c index a55bc0cf7..25ace4a25 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_rpm.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_rpm.c @@ -144,7 +144,7 @@ rpm_bidder_init(struct archive_read_filter *self) self->code = ARCHIVE_FILTER_RPM; self->name = "rpm"; - rpm = (struct rpm *)calloc(1, sizeof(*rpm)); + rpm = calloc(1, sizeof(*rpm)); if (rpm == NULL) { archive_set_error(&self->archive->archive, ENOMEM, "Can't allocate data for rpm"); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_uu.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_uu.c index de61c4a88..242d14b5e 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_uu.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_uu.c @@ -379,7 +379,7 @@ uudecode_bidder_init(struct archive_read_filter *self) self->code = ARCHIVE_FILTER_UU; self->name = "uu"; - uudecode = (struct uudecode *)calloc(1, sizeof(*uudecode)); + uudecode = calloc(1, sizeof(*uudecode)); out_buff = malloc(OUT_BUFF_SIZE); in_buff = malloc(IN_BUFF_SIZE); if (uudecode == NULL || out_buff == NULL || in_buff == NULL) { diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_xz.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_xz.c index fb9317d38..cb13291b9 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_xz.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_xz.c @@ -476,8 +476,8 @@ xz_lzma_bidder_init(struct archive_read_filter *self) struct private_data *state; int ret; - state = (struct private_data *)calloc(1, sizeof(*state)); - out_block = (unsigned char *)malloc(out_block_size); + state = calloc(1, sizeof(*state)); + out_block = malloc(out_block_size); if (state == NULL || out_block == NULL) { archive_set_error(&self->archive->archive, ENOMEM, "Can't allocate data for xz decompression"); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_zstd.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_zstd.c index 885c10fa0..4a88b4634 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_zstd.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_zstd.c @@ -175,8 +175,8 @@ zstd_bidder_init(struct archive_read_filter *self) self->code = ARCHIVE_FILTER_ZSTD; self->name = "zstd"; - state = (struct private_data *)calloc(1, sizeof(*state)); - out_block = (unsigned char *)malloc(out_block_size); + state = calloc(1, sizeof(*state)); + out_block = malloc(out_block_size); dstream = ZSTD_createDStream(); if (state == NULL || out_block == NULL || dstream == NULL) { diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c index 8067fba18..662238ccd 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c @@ -771,29 +771,27 @@ archive_read_format_7zip_read_header(struct archive_read *a, if (zip_entry->attr & supported_attrs) { char *fflags_text, *ptr; - /* allocate for "rdonly,hidden,system," */ - fflags_text = malloc(22 * sizeof(char)); + /* allocate for ",rdonly,hidden,system" */ + fflags_text = malloc(22 * sizeof(*fflags_text)); if (fflags_text != NULL) { ptr = fflags_text; - if (zip_entry->attr & FILE_ATTRIBUTE_READONLY) { - strcpy(ptr, "rdonly,"); - ptr = ptr + 7; - } - if (zip_entry->attr & FILE_ATTRIBUTE_HIDDEN) { - strcpy(ptr, "hidden,"); - ptr = ptr + 7; - } - if (zip_entry->attr & FILE_ATTRIBUTE_SYSTEM) { - strcpy(ptr, "system,"); - ptr = ptr + 7; - } - if (ptr > fflags_text) { - /* Delete trailing comma */ - *(ptr - 1) = '\0'; - archive_entry_copy_fflags_text(entry, - fflags_text); - } - free(fflags_text); + if (zip_entry->attr & FILE_ATTRIBUTE_READONLY) { + strcpy(ptr, ",rdonly"); + ptr = ptr + 7; + } + if (zip_entry->attr & FILE_ATTRIBUTE_HIDDEN) { + strcpy(ptr, ",hidden"); + ptr = ptr + 7; + } + if (zip_entry->attr & FILE_ATTRIBUTE_SYSTEM) { + strcpy(ptr, ",system"); + ptr = ptr + 7; + } + if (ptr > fflags_text) { + archive_entry_copy_fflags_text(entry, + fflags_text + 1); + } + free(fflags_text); } } @@ -842,9 +840,20 @@ archive_read_format_7zip_read_header(struct archive_read *a, zip_entry->mode |= AE_IFREG; archive_entry_set_mode(entry, zip_entry->mode); } else { + struct archive_string_conv* utf8_conv; + symname[symsize] = '\0'; - archive_entry_copy_symlink(entry, - (const char *)symname); + + /* Symbolic links are embedded as UTF-8 strings */ + utf8_conv = archive_string_conversion_from_charset(&a->archive, + "UTF-8", 1); + if (utf8_conv == NULL) { + free(symname); + return ARCHIVE_FATAL; + } + + archive_entry_copy_symlink_l(entry, (const char*)symname, symsize, + utf8_conv); } free(symname); archive_entry_set_size(entry, 0); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_ar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_ar.c index b0d1ddbc5..6dfe2939d 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_ar.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_ar.c @@ -103,7 +103,7 @@ archive_read_support_format_ar(struct archive *_a) archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, "archive_read_support_format_ar"); - ar = (struct ar *)calloc(1, sizeof(*ar)); + ar = calloc(1, sizeof(*ar)); if (ar == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate ar data"); @@ -368,7 +368,7 @@ _ar_read_header(struct archive_read *a, struct archive_entry *entry, return (ARCHIVE_FATAL); } /* Store it in the entry. */ - p = (char *)malloc(bsd_name_length + 1); + p = malloc(bsd_name_length + 1); if (p == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate fname buffer"); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c index d5be04ba5..6c0254644 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c @@ -356,7 +356,7 @@ archive_read_support_format_cab(struct archive *_a) archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, "archive_read_support_format_cab"); - cab = (struct cab *)calloc(1, sizeof(*cab)); + cab = calloc(1, sizeof(*cab)); if (cab == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate CAB data"); @@ -717,7 +717,7 @@ cab_read_header(struct archive_read *a) /* * Read CFFOLDER. */ - hd->folder_array = (struct cffolder *)calloc( + hd->folder_array = calloc( hd->folder_count, sizeof(struct cffolder)); if (hd->folder_array == NULL) goto nomem; @@ -780,7 +780,7 @@ cab_read_header(struct archive_read *a) cab->cab_offset += skip; } /* Allocate memory for CFDATA */ - hd->file_array = (struct cffile *)calloc( + hd->file_array = calloc( hd->file_count, sizeof(struct cffile)); if (hd->file_array == NULL) goto nomem; @@ -1412,7 +1412,7 @@ cab_read_ahead_cfdata_deflate(struct archive_read *a, ssize_t *avail) if (cab->uncompressed_buffer == NULL) { cab->uncompressed_buffer_size = 0x8000; cab->uncompressed_buffer - = (unsigned char *)malloc(cab->uncompressed_buffer_size); + = malloc(cab->uncompressed_buffer_size); if (cab->uncompressed_buffer == NULL) { archive_set_error(&a->archive, ENOMEM, "No memory for CAB reader"); @@ -1641,7 +1641,7 @@ cab_read_ahead_cfdata_lzx(struct archive_read *a, ssize_t *avail) if (cab->uncompressed_buffer == NULL) { cab->uncompressed_buffer_size = 0x8000; cab->uncompressed_buffer - = (unsigned char *)malloc(cab->uncompressed_buffer_size); + = malloc(cab->uncompressed_buffer_size); if (cab->uncompressed_buffer == NULL) { archive_set_error(&a->archive, ENOMEM, "No memory for CAB reader"); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c index 69752cbb0..42a89c1b6 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c @@ -228,7 +228,7 @@ archive_read_support_format_cpio(struct archive *_a) archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, "archive_read_support_format_cpio"); - cpio = (struct cpio *)calloc(1, sizeof(*cpio)); + cpio = calloc(1, sizeof(*cpio)); if (cpio == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate cpio data"); return (ARCHIVE_FATAL); @@ -1088,7 +1088,7 @@ record_hardlink(struct archive_read *a, } } - le = (struct links_entry *)malloc(sizeof(struct links_entry)); + le = malloc(sizeof(struct links_entry)); if (le == NULL) { archive_set_error(&a->archive, ENOMEM, "Out of memory adding file to list"); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c index 137206a58..5cae9ae26 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c @@ -273,7 +273,7 @@ struct file_info { char re; /* Having RRIP "RE" extension. */ char re_descendant; uint64_t cl_offset; /* Having RRIP "CL" extension. */ - int birthtime_is_set; + int time_is_set; /* Bitmask indicating which times are known */ time_t birthtime; /* File created time. */ time_t mtime; /* File last modified time. */ time_t atime; /* File last accessed time. */ @@ -306,6 +306,11 @@ struct file_info { } rede_files; }; +#define BIRTHTIME_IS_SET 1 +#define MTIME_IS_SET 2 +#define ATIME_IS_SET 4 +#define CTIME_IS_SET 8 + struct heap_queue { struct file_info **files; int allocated; @@ -394,7 +399,9 @@ static void dump_isodirrec(FILE *, const unsigned char *isodirrec); #endif static time_t time_from_tm(struct tm *); static time_t isodate17(const unsigned char *); +static int isodate17_valid(const unsigned char *); static time_t isodate7(const unsigned char *); +static int isodate7_valid(const unsigned char *); static int isBootRecord(struct iso9660 *, const unsigned char *); static int isVolumePartition(struct iso9660 *, const unsigned char *); static int isVDSetTerminator(struct iso9660 *, const unsigned char *); @@ -456,7 +463,7 @@ archive_read_support_format_iso9660(struct archive *_a) archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, "archive_read_support_format_iso9660"); - iso9660 = (struct iso9660 *)calloc(1, sizeof(*iso9660)); + iso9660 = calloc(1, sizeof(*iso9660)); if (iso9660 == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate iso9660 data"); @@ -1351,13 +1358,22 @@ archive_read_format_iso9660_read_header(struct archive_read *a, archive_entry_set_uid(entry, file->uid); archive_entry_set_gid(entry, file->gid); archive_entry_set_nlink(entry, file->nlinks); - if (file->birthtime_is_set) + if ((file->time_is_set & BIRTHTIME_IS_SET)) archive_entry_set_birthtime(entry, file->birthtime, 0); else archive_entry_unset_birthtime(entry); - archive_entry_set_mtime(entry, file->mtime, 0); - archive_entry_set_ctime(entry, file->ctime, 0); - archive_entry_set_atime(entry, file->atime, 0); + if ((file->time_is_set & MTIME_IS_SET)) + archive_entry_set_mtime(entry, file->mtime, 0); + else + archive_entry_unset_mtime(entry); + if ((file->time_is_set & CTIME_IS_SET)) + archive_entry_set_ctime(entry, file->ctime, 0); + else + archive_entry_unset_ctime(entry); + if ((file->time_is_set & ATIME_IS_SET)) + archive_entry_set_atime(entry, file->atime, 0); + else + archive_entry_unset_atime(entry); /* N.B.: Rock Ridge supports 64-bit device numbers. */ archive_entry_set_rdev(entry, (dev_t)file->rdev); archive_entry_set_size(entry, iso9660->entry_bytes_remaining); @@ -1889,7 +1905,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent, } /* Create a new file entry and copy data from the ISO dir record. */ - file = (struct file_info *)calloc(1, sizeof(*file)); + file = calloc(1, sizeof(*file)); if (file == NULL) { archive_set_error(&a->archive, ENOMEM, "No memory for file entry"); @@ -1898,8 +1914,11 @@ parse_file_info(struct archive_read *a, struct file_info *parent, file->parent = parent; file->offset = offset; file->size = fsize; - file->mtime = isodate7(isodirrec + DR_date_offset); - file->ctime = file->atime = file->mtime; + if (isodate7_valid(isodirrec + DR_date_offset)) { + file->time_is_set |= MTIME_IS_SET | ATIME_IS_SET | CTIME_IS_SET; + file->mtime = isodate7(isodirrec + DR_date_offset); + file->ctime = file->atime = file->mtime; + } file->rede_files.first = NULL; file->rede_files.last = &(file->rede_files.first); @@ -2573,51 +2592,73 @@ parse_rockridge_TF1(struct file_info *file, const unsigned char *data, /* Use 17-byte time format. */ if ((flag & 1) && data_length >= 17) { /* Create time. */ - file->birthtime_is_set = 1; - file->birthtime = isodate17(data); + if (isodate17_valid(data)) { + file->time_is_set |= BIRTHTIME_IS_SET; + file->birthtime = isodate17(data); + } data += 17; data_length -= 17; } if ((flag & 2) && data_length >= 17) { /* Modify time. */ - file->mtime = isodate17(data); + if (isodate17_valid(data)) { + file->time_is_set |= MTIME_IS_SET; + file->mtime = isodate17(data); + } data += 17; data_length -= 17; } if ((flag & 4) && data_length >= 17) { /* Access time. */ - file->atime = isodate17(data); + if (isodate17_valid(data)) { + file->time_is_set |= ATIME_IS_SET; + file->atime = isodate17(data); + } data += 17; data_length -= 17; } if ((flag & 8) && data_length >= 17) { /* Attribute change time. */ - file->ctime = isodate17(data); + if (isodate17_valid(data)) { + file->time_is_set |= CTIME_IS_SET; + file->ctime = isodate17(data); + } } } else { /* Use 7-byte time format. */ if ((flag & 1) && data_length >= 7) { /* Create time. */ - file->birthtime_is_set = 1; - file->birthtime = isodate7(data); + if (isodate7_valid(data)) { + file->time_is_set |= BIRTHTIME_IS_SET; + file->birthtime = isodate7(data); + } data += 7; data_length -= 7; } if ((flag & 2) && data_length >= 7) { /* Modify time. */ - file->mtime = isodate7(data); + if (isodate7_valid(data)) { + file->time_is_set |= MTIME_IS_SET; + file->mtime = isodate7(data); + } data += 7; data_length -= 7; } if ((flag & 4) && data_length >= 7) { /* Access time. */ - file->atime = isodate7(data); + if (isodate7_valid(data)) { + file->time_is_set |= ATIME_IS_SET; + file->atime = isodate7(data); + } data += 7; data_length -= 7; } if ((flag & 8) && data_length >= 7) { /* Attribute change time. */ - file->ctime = isodate7(data); + if (isodate7_valid(data)) { + file->time_is_set |= CTIME_IS_SET; + file->ctime = isodate7(data); + } } } } @@ -3228,6 +3269,56 @@ isValid733Integer(const unsigned char *p) && p[3] == p[4]); } +static int +isodate7_valid(const unsigned char *v) +{ + int year = v[0]; + int month = v[1]; + int day = v[2]; + int hour = v[3]; + int minute = v[4]; + int second = v[5]; + int gmt_off = (signed char)v[6]; + + /* ECMA-119 9.1.5 "If all seven values are zero, it shall mean + * that the date is unspecified" */ + if (year == 0 + && month == 0 + && day == 0 + && hour == 0 + && minute == 0 + && second == 0 + && gmt_off == 0) + return 0; + /* + * Sanity-test each individual field + */ + /* Year can have any value */ + /* Month must be 1-12 */ + if (month < 1 || month > 12) + return 0; + /* Day must be 1-31 */ + if (day < 1 || day > 31) + return 0; + /* Hour must be 0-23 */ + if (hour > 23) + return 0; + /* Minute must be 0-59 */ + if (minute > 59) + return 0; + /* second must be 0-59 according to ECMA-119 9.1.5 */ + /* BUT: we should probably allow for the time being in UTC, which + allows up to 61 seconds in a minute in certain cases */ + if (second > 61) + return 0; + /* Offset from GMT must be -48 to +52 */ + if (gmt_off < -48 || gmt_off > +52) + return 0; + + /* All tests pass, this is OK */ + return 1; +} + static time_t isodate7(const unsigned char *v) { @@ -3254,6 +3345,67 @@ isodate7(const unsigned char *v) return (t); } +static int +isodate17_valid(const unsigned char *v) +{ + /* First 16 bytes are all ASCII digits */ + for (int i = 0; i < 16; i++) { + if (v[i] < '0' || v[i] > '9') + return 0; + } + + int year = (v[0] - '0') * 1000 + (v[1] - '0') * 100 + + (v[2] - '0') * 10 + (v[3] - '0'); + int month = (v[4] - '0') * 10 + (v[5] - '0'); + int day = (v[6] - '0') * 10 + (v[7] - '0'); + int hour = (v[8] - '0') * 10 + (v[9] - '0'); + int minute = (v[10] - '0') * 10 + (v[11] - '0'); + int second = (v[12] - '0') * 10 + (v[13] - '0'); + int hundredths = (v[14] - '0') * 10 + (v[15] - '0'); + int gmt_off = (signed char)v[16]; + + if (year == 0 && month == 0 && day == 0 + && hour == 0 && minute == 0 && second == 0 + && hundredths == 0 && gmt_off == 0) + return 0; + /* + * Sanity-test each individual field + */ + + /* Year must be 1900-2300 */ + /* (Not specified in ECMA-119, but these seem + like reasonable limits. */ + if (year < 1900 || year > 2300) + return 0; + /* Month must be 1-12 */ + if (month < 1 || month > 12) + return 0; + /* Day must be 1-31 */ + if (day < 1 || day > 31) + return 0; + /* Hour must be 0-23 */ + if (hour > 23) + return 0; + /* Minute must be 0-59 */ + if (minute > 59) + return 0; + /* second must be 0-59 according to ECMA-119 9.1.5 */ + /* BUT: we should probably allow for the time being in UTC, which + allows up to 61 seconds in a minute in certain cases */ + if (second > 61) + return 0; + /* Hundredths must be 0-99 */ + if (hundredths > 99) + return 0; + /* Offset from GMT must be -48 to +52 */ + if (gmt_off < -48 || gmt_off > +52) + return 0; + + /* All tests pass, this is OK */ + return 1; + +} + static time_t isodate17(const unsigned char *v) { diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c index e417baad1..c7cbad272 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c @@ -265,7 +265,7 @@ archive_read_support_format_lha(struct archive *_a) archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, "archive_read_support_format_lha"); - lha = (struct lha *)calloc(1, sizeof(*lha)); + lha = calloc(1, sizeof(*lha)); if (lha == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate lha data"); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c index 6971228ee..ba0e49de2 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c @@ -273,7 +273,7 @@ archive_read_support_format_mtree(struct archive *_a) archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, "archive_read_support_format_mtree"); - mtree = (struct mtree *)calloc(1, sizeof(*mtree)); + mtree = calloc(1, sizeof(*mtree)); if (mtree == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate mtree data"); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c index 2c3b4ea4d..9fdae43ee 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c @@ -736,7 +736,7 @@ archive_read_support_format_rar(struct archive *_a) archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, "archive_read_support_format_rar"); - rar = (struct rar *)calloc(1, sizeof(*rar)); + rar = calloc(1, sizeof(*rar)); if (rar == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate rar data"); @@ -1373,7 +1373,7 @@ read_header(struct archive_read *a, struct archive_entry *entry, char unp_size[8]; int ttime; struct archive_string_conv *sconv, *fn_sconv; - unsigned long crc32_val; + uint32_t crc32_computed, crc32_read; int ret = (ARCHIVE_OK), ret2; char *newptr; size_t newsize; @@ -1404,7 +1404,7 @@ read_header(struct archive_read *a, struct archive_entry *entry, "Invalid header size"); return (ARCHIVE_FATAL); } - crc32_val = crc32(0, (const unsigned char *)p + 2, 7 - 2); + crc32_computed = crc32(0, (const unsigned char *)p + 2, 7 - 2); __archive_read_consume(a, 7); if (!(rar->file_flags & FHD_SOLID)) @@ -1438,8 +1438,9 @@ read_header(struct archive_read *a, struct archive_entry *entry, return (ARCHIVE_FATAL); /* File Header CRC check. */ - crc32_val = crc32(crc32_val, h, (unsigned)(header_size - 7)); - if ((crc32_val & 0xffff) != archive_le16dec(rar_header.crc)) { + crc32_computed = crc32(crc32_computed, h, (unsigned)(header_size - 7)); + crc32_read = archive_le16dec(rar_header.crc); + if ((crc32_computed & 0xffff) != crc32_read) { #ifndef DONT_FAIL_ON_CRC_ERROR archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Header CRC error"); @@ -2804,9 +2805,7 @@ make_table(struct archive_read *a, struct huffman_code *code) else code->tablesize = code->maxlength; - code->table = - (struct huffman_table_entry *)calloc(1, sizeof(*code->table) - * ((size_t)1 << code->tablesize)); + code->table = calloc(1U << code->tablesize, sizeof(*code->table)); return make_table_recurse(a, code, 0, code->table, 0, code->tablesize); } diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar5.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar5.c index 973cd42be..944270ef0 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar5.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar5.c @@ -210,7 +210,11 @@ struct comp_state { or just a part of it. */ uint8_t block_parsing_finished : 1; - signed int notused : 4; + /* Flag used to indicate that a previous file using this buffer was + encrypted, meaning no data in the buffer can be trusted */ + uint8_t data_encrypted : 1; + + signed int notused : 3; int flags; /* Uncompression flags. */ int method; /* Uncompression algorithm method. */ @@ -352,6 +356,12 @@ struct rar5 { /* The header of currently processed RARv5 block. Used in main * decompression logic loop. */ struct compressed_block_header last_block_hdr; + + /* + * Custom field to denote that this archive contains encrypted entries + */ + int has_encrypted_entries; + int headers_are_encrypted; }; /* Forward function declarations. */ @@ -535,8 +545,7 @@ static void write_filter_data(struct rar5* rar, uint32_t offset, /* Allocates a new filter descriptor and adds it to the filter array. */ static struct filter_info* add_new_filter(struct rar5* rar) { - struct filter_info* f = - (struct filter_info*) calloc(1, sizeof(struct filter_info)); + struct filter_info* f = calloc(1, sizeof(*f)); if(!f) { return NULL; @@ -1597,6 +1606,7 @@ static int process_head_file_extra(struct archive_read* a, if(!read_var(a, &extra_field_id, &var_size)) return ARCHIVE_EOF; + extra_field_size -= var_size; extra_data_size -= var_size; if(ARCHIVE_OK != consume(a, var_size)) { return ARCHIVE_EOF; @@ -1624,12 +1634,19 @@ static int process_head_file_extra(struct archive_read* a, &extra_data_size); break; case EX_CRYPT: + /* Mark the entry as encrypted */ + archive_entry_set_is_data_encrypted(e, 1); + rar->has_encrypted_entries = 1; + rar->cstate.data_encrypted = 1; /* fallthrough */ case EX_SUBDATA: /* fallthrough */ default: /* Skip unsupported entry. */ - return consume(a, extra_data_size); + extra_data_size -= extra_field_size; + if (ARCHIVE_OK != consume(a, extra_field_size)) { + return ARCHIVE_EOF; + } } } @@ -1747,9 +1764,11 @@ static int process_head_file(struct archive_read* a, struct rar5* rar, rar->file.solid = (compression_info & SOLID) > 0; /* Archives which declare solid files without initializing the window - * buffer first are invalid. */ + * buffer first are invalid, unless previous data was encrypted, in + * which case we may never have had the chance */ - if(rar->file.solid > 0 && rar->cstate.window_buf == NULL) { + if(rar->file.solid > 0 && rar->cstate.data_encrypted == 0 && + rar->cstate.window_buf == NULL) { archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Declared solid file, but no window buffer " "initialized yet."); @@ -1778,6 +1797,8 @@ static int process_head_file(struct archive_read* a, struct rar5* rar, return ARCHIVE_FATAL; } } + else + rar->cstate.data_encrypted = 0; /* Reset for new buffer */ if(rar->cstate.window_size < (ssize_t) window_size && rar->cstate.window_buf) @@ -1846,27 +1867,25 @@ static int process_head_file(struct archive_read* a, struct rar5* rar, if (file_attr & (ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM)) { char *fflags_text, *ptr; - /* allocate for "rdonly,hidden,system," */ - fflags_text = malloc(22 * sizeof(char)); + /* allocate for ",rdonly,hidden,system" */ + fflags_text = malloc(22 * sizeof(*fflags_text)); if (fflags_text != NULL) { ptr = fflags_text; if (file_attr & ATTR_READONLY) { - strcpy(ptr, "rdonly,"); + strcpy(ptr, ",rdonly"); ptr = ptr + 7; } if (file_attr & ATTR_HIDDEN) { - strcpy(ptr, "hidden,"); + strcpy(ptr, ",hidden"); ptr = ptr + 7; } if (file_attr & ATTR_SYSTEM) { - strcpy(ptr, "system,"); + strcpy(ptr, ",system"); ptr = ptr + 7; } if (ptr > fflags_text) { - /* Delete trailing comma */ - *(ptr - 1) = '\0'; archive_entry_copy_fflags_text(entry, - fflags_text); + fflags_text + 1); } free(fflags_text); } @@ -2282,6 +2301,10 @@ static int process_base_block(struct archive_read* a, ret = process_head_file(a, rar, entry, header_flags); return ret; case HEAD_CRYPT: + archive_entry_set_is_metadata_encrypted(entry, 1); + archive_entry_set_is_data_encrypted(entry, 1); + rar->has_encrypted_entries = 1; + rar->headers_are_encrypted = 1; archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Encryption is not supported"); @@ -2426,6 +2449,14 @@ static int rar5_read_header(struct archive_read *a, struct rar5* rar = get_context(a); int ret; + /* + * It should be sufficient to call archive_read_next_header() for + * a reader to determine if an entry is encrypted or not. + */ + if (rar->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) { + rar->has_encrypted_entries = 0; + } + if(rar->header_initialized == 0) { init_header(a); if ((ret = try_skip_sfx(a)) < ARCHIVE_WARN) @@ -4097,6 +4128,16 @@ static int rar5_read_data(struct archive_read *a, const void **buff, if (size) *size = 0; + if (rar->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) { + rar->has_encrypted_entries = 0; + } + + if (rar->headers_are_encrypted || rar->cstate.data_encrypted) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "Reading encrypted data is not currently supported"); + return ARCHIVE_FATAL; + } + if(rar->file.dir > 0) { /* Don't process any data if this file entry was declared * as a directory. This is needed, because entries marked as @@ -4148,11 +4189,14 @@ static int rar5_read_data(struct archive_read *a, const void **buff, static int rar5_read_data_skip(struct archive_read *a) { struct rar5* rar = get_context(a); - if(rar->main.solid) { + if(rar->main.solid && (rar->cstate.data_encrypted == 0)) { /* In solid archives, instead of skipping the data, we need to * extract it, and dispose the result. The side effect of this * operation will be setting up the initial window buffer state - * needed to be able to extract the selected file. */ + * needed to be able to extract the selected file. Note that + * this is only possible when data withing this solid block is + * not encrypted, in which case we'll skip and fail if the user + * tries to read data. */ int ret; @@ -4228,14 +4272,19 @@ static int rar5_cleanup(struct archive_read *a) { static int rar5_capabilities(struct archive_read * a) { (void) a; - return 0; + return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA + | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA); } static int rar5_has_encrypted_entries(struct archive_read *_a) { - (void) _a; + if (_a && _a->format) { + struct rar5 *rar = (struct rar5 *)_a->format->data; + if (rar) { + return rar->has_encrypted_entries; + } + } - /* Unsupported for now. */ - return ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED; + return ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW; } static int rar5_init(struct rar5* rar) { @@ -4244,6 +4293,12 @@ static int rar5_init(struct rar5* rar) { if(CDE_OK != cdeque_init(&rar->cstate.filters, 8192)) return ARCHIVE_FATAL; + /* + * Until enough data has been read, we cannot tell about + * any encrypted entries yet. + */ + rar->has_encrypted_entries = ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW; + return ARCHIVE_OK; } diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_raw.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_raw.c index efdbf276b..e935396dd 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_raw.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_raw.c @@ -61,7 +61,7 @@ archive_read_support_format_raw(struct archive *_a) archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, "archive_read_support_format_raw"); - info = (struct raw_info *)calloc(1, sizeof(*info)); + info = calloc(1, sizeof(*info)); if (info == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate raw_info data"); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c index cb103c368..fba13785e 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c @@ -123,8 +123,6 @@ struct tar { struct archive_string entry_uname; struct archive_string entry_gname; struct archive_string entry_linkpath; - struct archive_string longname; - struct archive_string pax_global; struct archive_string line; int pax_hdrcharset_utf8; int64_t entry_bytes_remaining; @@ -258,7 +256,7 @@ archive_read_support_format_tar(struct archive *_a) archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, "archive_read_support_format_tar"); - tar = (struct tar *)calloc(1, sizeof(*tar)); + tar = calloc(1, sizeof(*tar)); if (tar == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate tar data"); @@ -298,8 +296,6 @@ archive_read_format_tar_cleanup(struct archive_read *a) archive_string_free(&tar->entry_gname); archive_string_free(&tar->entry_linkpath); archive_string_free(&tar->line); - archive_string_free(&tar->pax_global); - archive_string_free(&tar->longname); archive_string_free(&tar->localname); free(tar); (a->format->data) = NULL; @@ -631,8 +627,6 @@ archive_read_format_tar_read_data(struct archive_read *a, } *buff = __archive_read_ahead(a, 1, &bytes_read); - if (bytes_read < 0) - return (ARCHIVE_FATAL); if (*buff == NULL) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Truncated tar archive" @@ -727,6 +721,7 @@ tar_read_header(struct archive_read *a, struct tar *tar, archive_string_empty(&(tar->entry_pathname)); archive_string_empty(&(tar->entry_pathname_override)); archive_string_empty(&(tar->entry_uname)); + archive_string_empty(&tar->entry_linkpath); /* Ensure format is set. */ if (a->archive.archive_format_name == NULL) { @@ -749,8 +744,6 @@ tar_read_header(struct archive_read *a, struct tar *tar, /* Read 512-byte header record */ h = __archive_read_ahead(a, 512, &bytes); - if (bytes < 0) - return ((int)bytes); if (bytes == 0) { /* EOF at a block boundary. */ if (eof_fatal) { /* We've read a special header already; @@ -763,7 +756,7 @@ tar_read_header(struct archive_read *a, struct tar *tar, return (ARCHIVE_EOF); } } - if (bytes < 512) { /* Short block at EOF; this is bad. */ + if (h == NULL) { /* Short block at EOF; this is bad. */ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Truncated tar archive" @@ -1012,7 +1005,12 @@ checksum(struct archive_read *a, const void *h) if (sum == check) return (1); +#if DONT_FAIL_ON_CRC_ERROR + /* Speed up fuzzing by pretending the checksum is always right. */ + return (1); +#else return (0); +#endif } /* @@ -1043,16 +1041,14 @@ header_Solaris_ACL(struct archive_read *a, struct tar *tar, int64_t type; char *acl, *p; - /* - * read_body_to_string adds a NUL terminator, but we need a little - * more to make sure that we don't overrun acl_text later. - */ header = (const struct archive_entry_header_ustar *)h; size = (size_t)tar_atol(header->size, sizeof(header->size)); archive_string_init(&acl_text); err = read_body_to_string(a, tar, &acl_text, h, unconsumed); - if (err != ARCHIVE_OK) + if (err != ARCHIVE_OK) { + archive_string_free(&acl_text); return (err); + } /* TODO: Examine the first characters to see if this * is an AIX ACL descriptor. We'll likely never support @@ -1177,13 +1173,16 @@ header_gnu_longname(struct archive_read *a, struct tar *tar, struct archive_entry *entry, const void *h, size_t *unconsumed) { int err; + struct archive_string longname; - err = read_body_to_string(a, tar, &(tar->longname), h, unconsumed); - if (err != ARCHIVE_OK) - return (err); - if (archive_entry_copy_pathname_l(entry, tar->longname.s, - archive_strlen(&(tar->longname)), tar->sconv) != 0) - err = set_conversion_failed_error(a, tar->sconv, "Pathname"); + archive_string_init(&longname); + err = read_body_to_string(a, tar, &longname, h, unconsumed); + if (err == ARCHIVE_OK) { + if (archive_entry_copy_pathname_l(entry, longname.s, + archive_strlen(&longname), tar->sconv) != 0) + err = set_conversion_failed_error(a, tar->sconv, "Pathname"); + } + archive_string_free(&longname); return (err); } @@ -1520,9 +1519,17 @@ header_old_tar(struct archive_read *a, struct tar *tar, const struct archive_entry_header_ustar *header; int err = ARCHIVE_OK, err2; - /* Copy filename over (to ensure null termination). */ + /* + * Copy filename over (to ensure null termination). + * Skip if pathname was already set e.g. by header_gnu_longname() + */ header = (const struct archive_entry_header_ustar *)h; - if (archive_entry_copy_pathname_l(entry, + + const char *existing_pathname = archive_entry_pathname(entry); + const wchar_t *existing_wcs_pathname = archive_entry_pathname_w(entry); + if ((existing_pathname == NULL || existing_pathname[0] == '\0') + && (existing_wcs_pathname == NULL || existing_wcs_pathname[0] == '\0') && + archive_entry_copy_pathname_l(entry, header->name, sizeof(header->name), tar->sconv) != 0) { err = set_conversion_failed_error(a, tar->sconv, "Pathname"); if (err == ARCHIVE_FATAL) @@ -1630,6 +1637,9 @@ read_mac_metadata_blob(struct archive_read *a, tar_flush_unconsumed(a, unconsumed); data = __archive_read_ahead(a, msize, NULL); if (data == NULL) { + archive_set_error(&a->archive, EINVAL, + "Truncated archive" + " detected while reading macOS metadata"); *unconsumed = 0; return (ARCHIVE_FATAL); } @@ -1817,10 +1827,7 @@ header_pax_extension(struct archive_read *a, struct tar *tar, to_read = ext_size; } p = __archive_read_ahead(a, to_read, &did_read); - if (did_read < 0) { - return ((int)did_read); - } - if (did_read == 0) { /* EOF */ + if (p == NULL) { /* EOF */ archive_set_error(&a->archive, EINVAL, "Truncated tar archive" " detected while reading pax attribute name"); @@ -1895,6 +1902,7 @@ header_pax_extension(struct archive_read *a, struct tar *tar, name_length = p - name_start; p++; // Skip '=' + // Save the name before we consume it archive_strncpy(&attr_name, name_start, name_length); ext_size -= p - attr_start; @@ -1908,6 +1916,9 @@ header_pax_extension(struct archive_read *a, struct tar *tar, r = pax_attribute(a, tar, entry, attr_name.s, archive_strlen(&attr_name), value_length - 1, unconsumed); ext_size -= value_length - 1; + // Release the allocated attr_name (either here or before every return in this function) + archive_string_free(&attr_name); + if (r < ARCHIVE_WARN) { *unconsumed += ext_size + ext_padding; return (r); @@ -1917,10 +1928,7 @@ header_pax_extension(struct archive_read *a, struct tar *tar, /* Consume the `\n` that follows the pax attribute value. */ tar_flush_unconsumed(a, unconsumed); p = __archive_read_ahead(a, 1, &did_read); - if (did_read < 0) { - return ((int)did_read); - } - if (did_read == 0) { + if (p == NULL) { archive_set_error(&a->archive, EINVAL, "Truncated tar archive" " detected while completing pax attribute"); @@ -2302,13 +2310,15 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent err = ARCHIVE_FAILED; } else { p = __archive_read_ahead(a, value_length, &bytes_read); - if (p != NULL) { - if (gnu_sparse_01_parse(a, tar, p, value_length) != ARCHIVE_OK) { - err = ARCHIVE_WARN; - } - } else { + if (p == NULL) { + archive_set_error(&a->archive, EINVAL, + "Truncated archive" + " detected while reading GNU sparse data"); return (ARCHIVE_FATAL); } + if (gnu_sparse_01_parse(a, tar, p, value_length) != ARCHIVE_OK) { + err = ARCHIVE_WARN; + } } __archive_read_consume(a, value_length); return (err); @@ -2384,24 +2394,23 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent /* LIBARCHIVE.symlinktype */ if (value_length < 16) { p = __archive_read_ahead(a, value_length, &bytes_read); - if (p != NULL) { - if (value_length == 4 && memcmp(p, "file", 4) == 0) { - archive_entry_set_symlink_type(entry, - AE_SYMLINK_TYPE_FILE); - } else if (value_length == 3 && memcmp(p, "dir", 3) == 0) { - archive_entry_set_symlink_type(entry, - AE_SYMLINK_TYPE_DIRECTORY); - } else { - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "Unrecognized symlink type"); - err = ARCHIVE_WARN; - } - } else { + if (p == NULL) { archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Truncated tar archive " "detected while reading `symlinktype` attribute"); return (ARCHIVE_FATAL); } + if (value_length == 4 && memcmp(p, "file", 4) == 0) { + archive_entry_set_symlink_type(entry, + AE_SYMLINK_TYPE_FILE); + } else if (value_length == 3 && memcmp(p, "dir", 3) == 0) { + archive_entry_set_symlink_type(entry, + AE_SYMLINK_TYPE_DIRECTORY); + } else { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "Unrecognized symlink type"); + err = ARCHIVE_WARN; + } } else { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "symlink type is very long" @@ -2419,8 +2428,13 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent err = ARCHIVE_WARN; } else { p = __archive_read_ahead(a, value_length, &bytes_read); - if (p == NULL - || pax_attribute_LIBARCHIVE_xattr(entry, key, key_length, p, value_length)) { + if (p == NULL) { + archive_set_error(&a->archive, EINVAL, + "Truncated archive" + " detected while reading xattr information"); + return (ARCHIVE_FATAL); + } + if (pax_attribute_LIBARCHIVE_xattr(entry, key, key_length, p, value_length)) { /* TODO: Unable to parse xattr */ err = ARCHIVE_WARN; } @@ -2443,8 +2457,13 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent err = ARCHIVE_WARN; } else { p = __archive_read_ahead(a, value_length, &bytes_read); - if (p == NULL - || pax_attribute_RHT_security_selinux(entry, p, value_length)) { + if (p == NULL) { + archive_set_error(&a->archive, EINVAL, + "Truncated archive" + " detected while reading selinux data"); + return (ARCHIVE_FATAL); + } + if (pax_attribute_RHT_security_selinux(entry, p, value_length)) { /* TODO: Unable to parse xattr */ err = ARCHIVE_WARN; } @@ -2491,13 +2510,15 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent else if (key_length == 6 && memcmp(key, "fflags", 6) == 0) { if (value_length < fflags_limit) { p = __archive_read_ahead(a, value_length, &bytes_read); - if (p != NULL) { - archive_entry_copy_fflags_text_len(entry, p, value_length); - err = ARCHIVE_OK; - } else { + if (p == NULL) { /* Truncated archive */ - err = ARCHIVE_FATAL; + archive_set_error(&a->archive, EINVAL, + "Truncated archive" + " detected while reading SCHILY.fflags"); + return (ARCHIVE_FATAL); } + archive_entry_copy_fflags_text_len(entry, p, value_length); + err = ARCHIVE_OK; } else { /* Overlong fflags field */ err = ARCHIVE_WARN; @@ -2536,8 +2557,13 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent key += 6; if (value_length < xattr_limit) { p = __archive_read_ahead(a, value_length, &bytes_read); - if (p == NULL - || pax_attribute_SCHILY_xattr(entry, key, key_length, p, value_length)) { + if (p == NULL) { + archive_set_error(&a->archive, EINVAL, + "Truncated archive" + " detected while reading SCHILY.xattr"); + return (ARCHIVE_FATAL); + } + if (pax_attribute_SCHILY_xattr(entry, key, key_length, p, value_length)) { /* TODO: Unable to parse xattr */ err = ARCHIVE_WARN; } @@ -2560,16 +2586,18 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent /* SUN.holesdata */ if (value_length < sparse_map_limit) { p = __archive_read_ahead(a, value_length, &bytes_read); - if (p != NULL) { - err = pax_attribute_SUN_holesdata(a, tar, entry, p, value_length); - if (err < ARCHIVE_OK) { - archive_set_error(&a->archive, - ARCHIVE_ERRNO_MISC, - "Parse error: SUN.holesdata"); - } - } else { + if (p == NULL) { + archive_set_error(&a->archive, EINVAL, + "Truncated archive" + " detected while reading SUN.holesdata"); return (ARCHIVE_FATAL); } + err = pax_attribute_SUN_holesdata(a, tar, entry, p, value_length); + if (err < ARCHIVE_OK) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_MISC, + "Parse error: SUN.holesdata"); + } } else { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Unreasonably large sparse map: %d > %d", @@ -2621,26 +2649,25 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent if (key_length == 10 && memcmp(key, "hdrcharset", 10) == 0) { if (value_length < 64) { p = __archive_read_ahead(a, value_length, &bytes_read); - if (p != NULL) { - if (value_length == 6 - && memcmp(p, "BINARY", 6) == 0) { - /* Binary mode. */ - tar->pax_hdrcharset_utf8 = 0; - err = ARCHIVE_OK; - } else if (value_length == 23 - && memcmp(p, "ISO-IR 10646 2000 UTF-8", 23) == 0) { - tar->pax_hdrcharset_utf8 = 1; - err = ARCHIVE_OK; - } else { - /* TODO: Unrecognized character set */ - err = ARCHIVE_WARN; - } - } else { + if (p == NULL) { archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Truncated tar archive " "detected while reading hdrcharset attribute"); return (ARCHIVE_FATAL); } + if (value_length == 6 + && memcmp(p, "BINARY", 6) == 0) { + /* Binary mode. */ + tar->pax_hdrcharset_utf8 = 0; + err = ARCHIVE_OK; + } else if (value_length == 23 + && memcmp(p, "ISO-IR 10646 2000 UTF-8", 23) == 0) { + tar->pax_hdrcharset_utf8 = 1; + err = ARCHIVE_OK; + } else { + /* TODO: Unrecognized character set */ + err = ARCHIVE_WARN; + } } else { archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "hdrcharset attribute is unreasonably large (%d bytes)", @@ -2908,7 +2935,7 @@ gnu_add_sparse_entry(struct archive_read *a, struct tar *tar, { struct sparse_block *p; - p = (struct sparse_block *)calloc(1, sizeof(*p)); + p = calloc(1, sizeof(*p)); if (p == NULL) { archive_set_error(&a->archive, ENOMEM, "Out of memory"); return (ARCHIVE_FATAL); @@ -2973,9 +3000,7 @@ gnu_sparse_old_read(struct archive_read *a, struct tar *tar, do { tar_flush_unconsumed(a, unconsumed); data = __archive_read_ahead(a, 512, &bytes_read); - if (bytes_read < 0) - return (ARCHIVE_FATAL); - if (bytes_read < 512) { + if (data == NULL) { archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Truncated tar archive " "detected while reading sparse file data"); @@ -3395,7 +3420,7 @@ readline(struct archive_read *a, struct tar *tar, const char **start, tar_flush_unconsumed(a, unconsumed); t = __archive_read_ahead(a, 1, &bytes_read); - if (bytes_read <= 0) + if (bytes_read <= 0 || t == NULL) return (ARCHIVE_FATAL); s = t; /* Start of line? */ p = memchr(t, '\n', bytes_read); @@ -3436,7 +3461,7 @@ readline(struct archive_read *a, struct tar *tar, const char **start, } /* Read some more. */ t = __archive_read_ahead(a, 1, &bytes_read); - if (bytes_read <= 0) + if (bytes_read <= 0 || t == NULL) return (ARCHIVE_FATAL); s = t; /* Start of line? */ p = memchr(t, '\n', bytes_read); @@ -3480,7 +3505,7 @@ base64_decode(const char *s, size_t len, size_t *out_len) /* Allocate enough space to hold the entire output. */ /* Note that we may not use all of this... */ - out = (char *)malloc(len - len / 4 + 1); + out = malloc(len - len / 4 + 1); if (out == NULL) { *out_len = 0; return (NULL); @@ -3535,7 +3560,7 @@ url_decode(const char *in, size_t length) char *out, *d; const char *s; - out = (char *)malloc(length + 1); + out = malloc(length + 1); if (out == NULL) return (NULL); for (s = in, d = out; length > 0 && *s != '\0'; ) { diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c index 3e66ca1b7..355bb6e0a 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c @@ -450,7 +450,7 @@ archive_read_support_format_xar(struct archive *_a) archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, "archive_read_support_format_xar"); - xar = (struct xar *)calloc(1, sizeof(*xar)); + xar = calloc(1, sizeof(*xar)); if (xar == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate xar data"); diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c index 59db86cf2..5abbc0d15 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c @@ -1751,8 +1751,7 @@ zipx_xz_init(struct archive_read *a, struct zip *zip) free(zip->uncompressed_buffer); zip->uncompressed_buffer_size = 256 * 1024; - zip->uncompressed_buffer = - (uint8_t*) malloc(zip->uncompressed_buffer_size); + zip->uncompressed_buffer = malloc(zip->uncompressed_buffer_size); if (zip->uncompressed_buffer == NULL) { archive_set_error(&a->archive, ENOMEM, "No memory for xz decompression"); @@ -1862,8 +1861,7 @@ zipx_lzma_alone_init(struct archive_read *a, struct zip *zip) if(!zip->uncompressed_buffer) { zip->uncompressed_buffer_size = 256 * 1024; - zip->uncompressed_buffer = - (uint8_t*) malloc(zip->uncompressed_buffer_size); + zip->uncompressed_buffer = malloc(zip->uncompressed_buffer_size); if (zip->uncompressed_buffer == NULL) { archive_set_error(&a->archive, ENOMEM, @@ -2167,8 +2165,7 @@ zipx_ppmd8_init(struct archive_read *a, struct zip *zip) free(zip->uncompressed_buffer); zip->uncompressed_buffer_size = 256 * 1024; - zip->uncompressed_buffer = - (uint8_t*) malloc(zip->uncompressed_buffer_size); + zip->uncompressed_buffer = malloc(zip->uncompressed_buffer_size); if(zip->uncompressed_buffer == NULL) { archive_set_error(&a->archive, ENOMEM, @@ -2291,8 +2288,7 @@ zipx_bzip2_init(struct archive_read *a, struct zip *zip) free(zip->uncompressed_buffer); zip->uncompressed_buffer_size = 256 * 1024; - zip->uncompressed_buffer = - (uint8_t*) malloc(zip->uncompressed_buffer_size); + zip->uncompressed_buffer = malloc(zip->uncompressed_buffer_size); if (zip->uncompressed_buffer == NULL) { archive_set_error(&a->archive, ENOMEM, "No memory for bzip2 decompression"); @@ -2434,8 +2430,7 @@ zipx_zstd_init(struct archive_read *a, struct zip *zip) free(zip->uncompressed_buffer); zip->uncompressed_buffer_size = ZSTD_DStreamOutSize(); - zip->uncompressed_buffer = - (uint8_t*) malloc(zip->uncompressed_buffer_size); + zip->uncompressed_buffer = malloc(zip->uncompressed_buffer_size); if (zip->uncompressed_buffer == NULL) { archive_set_error(&a->archive, ENOMEM, "No memory for Zstd decompression"); @@ -2574,7 +2569,7 @@ zip_read_data_deflate(struct archive_read *a, const void **buff, if (zip->uncompressed_buffer == NULL) { zip->uncompressed_buffer_size = 256 * 1024; zip->uncompressed_buffer - = (unsigned char *)malloc(zip->uncompressed_buffer_size); + = malloc(zip->uncompressed_buffer_size); if (zip->uncompressed_buffer == NULL) { archive_set_error(&a->archive, ENOMEM, "No memory for ZIP decompression"); @@ -3600,7 +3595,7 @@ archive_read_support_format_zip_streamable(struct archive *_a) archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, "archive_read_support_format_zip"); - zip = (struct zip *)calloc(1, sizeof(*zip)); + zip = calloc(1, sizeof(*zip)); if (zip == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate zip data"); @@ -4392,7 +4387,7 @@ archive_read_support_format_zip_seekable(struct archive *_a) archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, "archive_read_support_format_zip_seekable"); - zip = (struct zip *)calloc(1, sizeof(*zip)); + zip = calloc(1, sizeof(*zip)); if (zip == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate zip data"); diff --git a/Utilities/cmlibarchive/libarchive/archive_string.c b/Utilities/cmlibarchive/libarchive/archive_string.c index 41bfe7af1..abf7ad669 100644 --- a/Utilities/cmlibarchive/libarchive/archive_string.c +++ b/Utilities/cmlibarchive/libarchive/archive_string.c @@ -313,7 +313,7 @@ archive_string_ensure(struct archive_string *as, size_t s) if (new_length < s) new_length = s; /* Now we can reallocate the buffer. */ - p = (char *)realloc(as->s, new_length); + p = realloc(as->s, new_length); if (p == NULL) { /* On failure, wipe the string and return NULL. */ archive_string_free(as); diff --git a/Utilities/cmlibarchive/libarchive/archive_util.c b/Utilities/cmlibarchive/libarchive/archive_util.c index 148921d40..3a84b2021 100644 --- a/Utilities/cmlibarchive/libarchive/archive_util.c +++ b/Utilities/cmlibarchive/libarchive/archive_util.c @@ -651,8 +651,7 @@ archive_utility_string_sort_helper(char **strings, unsigned int n) if (strcmp(strings[i], pivot) < 0) { lesser_count++; - tmp = (char **)realloc(lesser, - lesser_count * sizeof(char *)); + tmp = realloc(lesser, lesser_count * sizeof(*tmp)); if (!tmp) { free(greater); free(lesser); @@ -664,8 +663,7 @@ archive_utility_string_sort_helper(char **strings, unsigned int n) else { greater_count++; - tmp = (char **)realloc(greater, - greater_count * sizeof(char *)); + tmp = realloc(greater, greater_count * sizeof(*tmp)); if (!tmp) { free(greater); free(lesser); diff --git a/Utilities/cmlibarchive/libarchive/archive_write.c b/Utilities/cmlibarchive/libarchive/archive_write.c index e1a4f34bf..303c68688 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write.c +++ b/Utilities/cmlibarchive/libarchive/archive_write.c @@ -98,7 +98,7 @@ archive_write_new(void) struct archive_write *a; unsigned char *nulls; - a = (struct archive_write *)calloc(1, sizeof(*a)); + a = calloc(1, sizeof(*a)); if (a == NULL) return (NULL); a->archive.magic = ARCHIVE_WRITE_MAGIC; @@ -114,7 +114,7 @@ archive_write_new(void) /* Initialize a block of nulls for padding purposes. */ a->null_length = 1024; - nulls = (unsigned char *)calloc(a->null_length, sizeof(unsigned char)); + nulls = calloc(a->null_length, sizeof(unsigned char)); if (nulls == NULL) { free(a); return (NULL); @@ -367,8 +367,8 @@ archive_write_client_open(struct archive_write_filter *f) archive_write_get_bytes_in_last_block(f->archive); buffer_size = f->bytes_per_block; - state = (struct archive_none *)calloc(1, sizeof(*state)); - buffer = (char *)malloc(buffer_size); + state = calloc(1, sizeof(*state)); + buffer = malloc(buffer_size); if (state == NULL || buffer == NULL) { free(state); free(buffer); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_b64encode.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_b64encode.c index 3aca6d81d..2c361bfb9 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_b64encode.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_b64encode.c @@ -85,7 +85,7 @@ archive_write_add_filter_b64encode(struct archive *_a) archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC, ARCHIVE_STATE_NEW, "archive_write_add_filter_b64encode"); - state = (struct private_b64encode *)calloc(1, sizeof(*state)); + state = calloc(1, sizeof(*state)); if (state == NULL) { archive_set_error(f->archive, ENOMEM, "Can't allocate data for b64encode filter"); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_bzip2.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_bzip2.c index 4ee3bcf56..ea9e9b092 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_bzip2.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_bzip2.c @@ -177,8 +177,7 @@ archive_compressor_bzip2_open(struct archive_write_filter *f) bs -= bs % bpb; } data->compressed_buffer_size = bs; - data->compressed - = (char *)malloc(data->compressed_buffer_size); + data->compressed = malloc(data->compressed_buffer_size); if (data->compressed == NULL) { archive_set_error(f->archive, ENOMEM, "Can't allocate data for compression buffer"); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_compress.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_compress.c index e547e8872..a54a85754 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_compress.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_compress.c @@ -150,7 +150,7 @@ archive_compressor_compress_open(struct archive_write_filter *f) f->code = ARCHIVE_FILTER_COMPRESS; f->name = "compress"; - state = (struct private_data *)calloc(1, sizeof(*state)); + state = calloc(1, sizeof(*state)); if (state == NULL) { archive_set_error(f->archive, ENOMEM, "Can't allocate data for compression"); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_gzip.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_gzip.c index a272703a8..31d7e3053 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_gzip.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_gzip.c @@ -194,8 +194,7 @@ archive_compressor_gzip_open(struct archive_write_filter *f) bs -= bs % bpb; } data->compressed_buffer_size = bs; - data->compressed - = (unsigned char *)malloc(data->compressed_buffer_size); + data->compressed = malloc(data->compressed_buffer_size); if (data->compressed == NULL) { archive_set_error(f->archive, ENOMEM, "Can't allocate data for compression buffer"); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_uuencode.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_uuencode.c index 42dec8def..50bfeb6ea 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_uuencode.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_uuencode.c @@ -74,7 +74,7 @@ archive_write_add_filter_uuencode(struct archive *_a) archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC, ARCHIVE_STATE_NEW, "archive_write_add_filter_uu"); - state = (struct private_uuencode *)calloc(1, sizeof(*state)); + state = calloc(1, sizeof(*state)); if (state == NULL) { archive_set_error(f->archive, ENOMEM, "Can't allocate data for uuencode filter"); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_xz.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_xz.c index 5886f3a1f..dd8f31957 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_xz.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_xz.c @@ -319,8 +319,7 @@ archive_compressor_xz_open(struct archive_write_filter *f) bs -= bs % bpb; } data->compressed_buffer_size = bs; - data->compressed - = (unsigned char *)malloc(data->compressed_buffer_size); + data->compressed = malloc(data->compressed_buffer_size); if (data->compressed == NULL) { archive_set_error(f->archive, ENOMEM, "Can't allocate data for compression buffer"); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_zstd.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_zstd.c index 8a0b67ab2..ca421c981 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_zstd.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_zstd.c @@ -372,8 +372,7 @@ archive_compressor_zstd_open(struct archive_write_filter *f) } data->out.size = bs; data->out.pos = 0; - data->out.dst - = (unsigned char *)malloc(data->out.size); + data->out.dst = malloc(data->out.size); if (data->out.dst == NULL) { archive_set_error(f->archive, ENOMEM, "Can't allocate data for compression buffer"); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c b/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c index ad02a6cdc..34606cb8d 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c @@ -1991,7 +1991,7 @@ archive_write_disk_new(void) { struct archive_write_disk *a; - a = (struct archive_write_disk *)calloc(1, sizeof(*a)); + a = calloc(1, sizeof(*a)); if (a == NULL) return (NULL); a->archive.magic = ARCHIVE_WRITE_DISK_MAGIC; @@ -2758,7 +2758,7 @@ new_fixup(struct archive_write_disk *a, const char *pathname) { struct fixup_entry *fe; - fe = (struct fixup_entry *)calloc(1, sizeof(struct fixup_entry)); + fe = calloc(1, sizeof(struct fixup_entry)); if (fe == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate memory for a fixup"); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c b/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c index 774151ae2..086f79693 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c @@ -1362,23 +1362,23 @@ archive_write_disk_set_user_lookup(struct archive *_a, int64_t archive_write_disk_gid(struct archive *_a, const char *name, la_int64_t id) { - struct archive_write_disk *a = (struct archive_write_disk *)_a; - archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, - ARCHIVE_STATE_ANY, "archive_write_disk_gid"); - if (a->lookup_gid) - return (a->lookup_gid)(a->lookup_gid_data, name, id); - return (id); + struct archive_write_disk *a = (struct archive_write_disk *)_a; + archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, + ARCHIVE_STATE_ANY, "archive_write_disk_gid"); + if (a->lookup_gid) + return (a->lookup_gid)(a->lookup_gid_data, name, id); + return (id); } int64_t archive_write_disk_uid(struct archive *_a, const char *name, la_int64_t id) { - struct archive_write_disk *a = (struct archive_write_disk *)_a; - archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, - ARCHIVE_STATE_ANY, "archive_write_disk_uid"); - if (a->lookup_uid) - return (a->lookup_uid)(a->lookup_uid_data, name, id); - return (id); + struct archive_write_disk *a = (struct archive_write_disk *)_a; + archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, + ARCHIVE_STATE_ANY, "archive_write_disk_uid"); + if (a->lookup_uid) + return (a->lookup_uid)(a->lookup_uid_data, name, id); + return (id); } /* @@ -1389,7 +1389,7 @@ archive_write_disk_new(void) { struct archive_write_disk *a; - a = (struct archive_write_disk *)calloc(1, sizeof(*a)); + a = calloc(1, sizeof(*a)); if (a == NULL) return (NULL); a->archive.magic = ARCHIVE_WRITE_DISK_MAGIC; @@ -2079,7 +2079,7 @@ new_fixup(struct archive_write_disk *a, const wchar_t *pathname) { struct fixup_entry *fe; - fe = (struct fixup_entry *)calloc(1, sizeof(struct fixup_entry)); + fe = calloc(1, sizeof(struct fixup_entry)); if (fe == NULL) return (NULL); fe->next = a->fixup_list; @@ -2243,13 +2243,15 @@ guidword(wchar_t *p, int n) * Canonicalize the pathname. In particular, this strips duplicate * '\' characters, '.' elements, and trailing '\'. It also raises an * error for an empty path, a trailing '..' or (if _SECURE_NODOTDOT is - * set) any '..' in the path. + * set) any '..' in the path or (if ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS) + * if the path is absolute. */ static int cleanup_pathname(struct archive_write_disk *a, wchar_t *name) { wchar_t *dest, *src, *p, *top; wchar_t separator = L'\0'; + BOOL absolute_path = 0; p = name; if (*p == L'\0') { @@ -2271,6 +2273,8 @@ cleanup_pathname(struct archive_write_disk *a, wchar_t *name) if (p[0] == L'\\' && p[1] == L'\\' && (p[2] == L'.' || p[2] == L'?') && p[3] == L'\\') { + absolute_path = 1; + /* A path begin with "\\?\UNC\" */ if (p[2] == L'?' && (p[4] == L'U' || p[4] == L'u') && @@ -2318,9 +2322,10 @@ cleanup_pathname(struct archive_write_disk *a, wchar_t *name) return (ARCHIVE_FAILED); } else p += 4; - /* Network drive path like "\\\\file" */ - } else if (p[0] == L'\\' && p[1] == L'\\') { - p += 2; + /* Network drive path like "\\\\file" */ + } else if (p[0] == L'\\' && p[1] == L'\\') { + absolute_path = 1; + p += 2; } /* Skip leading drive letter from archives created @@ -2333,10 +2338,18 @@ cleanup_pathname(struct archive_write_disk *a, wchar_t *name) "Path is a drive name"); return (ARCHIVE_FAILED); } + + absolute_path = 1; + if (p[2] == L'\\') p += 2; } + if (absolute_path && (a->flags & ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS)) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Path is absolute"); + return (ARCHIVE_FAILED); + } + top = dest = src = p; /* Rewrite the path name if its character is a unusable. */ for (; *p != L'\0'; p++) { @@ -2829,7 +2842,7 @@ set_fflags(struct archive_write_disk *a) return (ARCHIVE_OK); return (set_fflags_platform(a->name, set, clear)); - } + } return (ARCHIVE_OK); } diff --git a/Utilities/cmlibarchive/libarchive/archive_write_open_fd.c b/Utilities/cmlibarchive/libarchive/archive_write_open_fd.c index a58ae0479..8a3f68d06 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_open_fd.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_open_fd.c @@ -62,7 +62,7 @@ archive_write_open_fd(struct archive *a, int fd) { struct write_fd_data *mine; - mine = (struct write_fd_data *)malloc(sizeof(*mine)); + mine = malloc(sizeof(*mine)); if (mine == NULL) { archive_set_error(a, ENOMEM, "No memory"); return (ARCHIVE_FATAL); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_open_file.c b/Utilities/cmlibarchive/libarchive/archive_write_open_file.c index d787da3af..4c6ebfb22 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_open_file.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_open_file.c @@ -59,7 +59,7 @@ archive_write_open_FILE(struct archive *a, FILE *f) { struct write_FILE_data *mine; - mine = (struct write_FILE_data *)malloc(sizeof(*mine)); + mine = malloc(sizeof(*mine)); if (mine == NULL) { archive_set_error(a, ENOMEM, "No memory"); return (ARCHIVE_FATAL); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_open_filename.c b/Utilities/cmlibarchive/libarchive/archive_write_open_filename.c index 7dc73d55f..6842b98d2 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_open_filename.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_open_filename.c @@ -98,7 +98,7 @@ open_filename(struct archive *a, int mbs_fn, const void *filename) struct write_file_data *mine; int r; - mine = (struct write_file_data *)calloc(1, sizeof(*mine)); + mine = calloc(1, sizeof(*mine)); if (mine == NULL) { archive_set_error(a, ENOMEM, "No memory"); return (ARCHIVE_FATAL); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_open_memory.c b/Utilities/cmlibarchive/libarchive/archive_write_open_memory.c index 609cc47d9..e31650447 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_open_memory.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_open_memory.c @@ -52,7 +52,7 @@ archive_write_open_memory(struct archive *a, void *buff, size_t buffSize, size_t { struct write_memory_data *mine; - mine = (struct write_memory_data *)calloc(1, sizeof(*mine)); + mine = calloc(1, sizeof(*mine)); if (mine == NULL) { archive_set_error(a, ENOMEM, "No memory"); return (ARCHIVE_FATAL); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c index 004e8eea7..a725ade78 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c @@ -521,7 +521,7 @@ _7z_write_header(struct archive_write *a, struct archive_entry *entry) */ if (archive_entry_filetype(entry) == AE_IFLNK) { ssize_t bytes; - const void *p = (const void *)archive_entry_symlink(entry); + const void *p = (const void *)archive_entry_symlink_utf8(entry); bytes = compress_out(a, p, (size_t)file->size, ARCHIVE_Z_RUN); if (bytes < 0) return ((int)bytes); @@ -1563,8 +1563,18 @@ file_new(struct archive_write *a, struct archive_entry *entry, archive_entry_set_size(entry, 0); if (archive_entry_filetype(entry) == AE_IFDIR) file->dir = 1; - else if (archive_entry_filetype(entry) == AE_IFLNK) - file->size = strlen(archive_entry_symlink(entry)); + else if (archive_entry_filetype(entry) == AE_IFLNK) { + const char* linkpath; + linkpath = archive_entry_symlink_utf8(entry); + if (linkpath == NULL) { + free(file); + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "symlink path could not be converted to UTF-8"); + return (ARCHIVE_FAILED); + } + else + file->size = strlen(linkpath); + } if (archive_entry_mtime_is_set(entry)) { file->flg |= MTIME_IS_SET; file->times[MTIME].time = archive_entry_mtime(entry); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_ar.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_ar.c index 38689d89b..e5e9c806b 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_ar.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_ar.c @@ -126,7 +126,7 @@ archive_write_set_format_ar(struct archive_write *a) if (a->format_free != NULL) (a->format_free)(a); - ar = (struct ar_w *)calloc(1, sizeof(*ar)); + ar = calloc(1, sizeof(*ar)); if (ar == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate ar data"); return (ARCHIVE_FATAL); @@ -246,7 +246,7 @@ archive_write_ar_header(struct archive_write *a, struct archive_entry *entry) return (ARCHIVE_WARN); } - se = (char *)malloc(strlen(filename) + 3); + se = malloc(strlen(filename) + 3); if (se == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate filename buffer"); @@ -379,7 +379,7 @@ archive_write_ar_data(struct archive_write *a, const void *buff, size_t s) return (ARCHIVE_WARN); } - ar->strtab = (char *)malloc(s + 1); + ar->strtab = malloc(s + 1); if (ar->strtab == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate strtab buffer"); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_binary.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_binary.c index a22d06ea3..aefb2ca6f 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_binary.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_binary.c @@ -185,7 +185,7 @@ archive_write_set_format_cpio_binary(struct archive *_a, int format) if (a->format_free != NULL) (a->format_free)(a); - cpio = (struct cpio *)calloc(1, sizeof(*cpio)); + cpio = calloc(1, sizeof(*cpio)); if (cpio == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate cpio data"); return (ARCHIVE_FATAL); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_newc.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_newc.c index 006736a1f..254d5a990 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_newc.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_newc.c @@ -116,7 +116,7 @@ archive_write_set_format_cpio_newc(struct archive *_a) if (a->format_free != NULL) (a->format_free)(a); - cpio = (struct cpio *)calloc(1, sizeof(*cpio)); + cpio = calloc(1, sizeof(*cpio)); if (cpio == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate cpio data"); return (ARCHIVE_FATAL); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_odc.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_odc.c index 6dce78b45..c72c6b279 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_odc.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_odc.c @@ -110,7 +110,7 @@ archive_write_set_format_cpio_odc(struct archive *_a) if (a->format_free != NULL) (a->format_free)(a); - cpio = (struct cpio *)calloc(1, sizeof(*cpio)); + cpio = calloc(1, sizeof(*cpio)); if (cpio == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate cpio data"); return (ARCHIVE_FATAL); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_gnutar.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_gnutar.c index 8979078ee..04b190de4 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_gnutar.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_gnutar.c @@ -174,7 +174,7 @@ archive_write_set_format_gnutar(struct archive *_a) struct archive_write *a = (struct archive_write *)_a; struct gnutar *gnutar; - gnutar = (struct gnutar *)calloc(1, sizeof(*gnutar)); + gnutar = calloc(1, sizeof(*gnutar)); if (gnutar == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate gnutar data"); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_pax.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_pax.c index 4aace4682..6e35f705e 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_pax.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_pax.c @@ -138,7 +138,7 @@ archive_write_set_format_pax(struct archive *_a) if (a->format_free != NULL) (a->format_free)(a); - pax = (struct pax *)calloc(1, sizeof(*pax)); + pax = calloc(1, sizeof(*pax)); if (pax == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate pax data"); @@ -1944,7 +1944,7 @@ url_encode(const char *in) } } - out = (char *)malloc(out_len + 1); + out = malloc(out_len + 1); if (out == NULL) return (NULL); @@ -1982,7 +1982,7 @@ base64_encode(const char *s, size_t len) char *d, *out; /* 3 bytes becomes 4 chars, but round up and allow for trailing NUL */ - out = (char *)malloc((len * 4 + 2) / 3 + 1); + out = malloc((len * 4 + 2) / 3 + 1); if (out == NULL) return (NULL); d = out; @@ -2037,7 +2037,7 @@ _sparse_list_add_block(struct pax *pax, int64_t offset, int64_t length, { struct sparse_block *sb; - sb = (struct sparse_block *)malloc(sizeof(*sb)); + sb = malloc(sizeof(*sb)); if (sb == NULL) return (ARCHIVE_FATAL); sb->next = NULL; diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_raw.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_raw.c index feff93697..ff3e9ae0e 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_raw.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_raw.c @@ -58,7 +58,7 @@ archive_write_set_format_raw(struct archive *_a) if (a->format_free != NULL) (a->format_free)(a); - raw = (struct raw *)calloc(1, sizeof(*raw)); + raw = calloc(1, sizeof(*raw)); if (raw == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate raw data"); return (ARCHIVE_FATAL); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c index da2bc0ca3..be9f78ce9 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c @@ -113,7 +113,7 @@ archive_write_set_format_shar(struct archive *_a) if (a->format_free != NULL) (a->format_free)(a); - shar = (struct shar *)calloc(1, sizeof(*shar)); + shar = calloc(1, sizeof(*shar)); if (shar == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate shar data"); return (ARCHIVE_FATAL); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_ustar.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_ustar.c index 9dc6e71f1..09b71fe66 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_ustar.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_ustar.c @@ -183,7 +183,7 @@ archive_write_set_format_ustar(struct archive *_a) return (ARCHIVE_FATAL); } - ustar = (struct ustar *)calloc(1, sizeof(*ustar)); + ustar = calloc(1, sizeof(*ustar)); if (ustar == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate ustar data"); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_v7tar.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_v7tar.c index ffb420f08..2598fc076 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_v7tar.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_v7tar.c @@ -160,7 +160,7 @@ archive_write_set_format_v7tar(struct archive *_a) return (ARCHIVE_FATAL); } - v7tar = (struct v7tar *)calloc(1, sizeof(*v7tar)); + v7tar = calloc(1, sizeof(*v7tar)); if (v7tar == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate v7tar data"); diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c index 40c3b0cac..c63b545eb 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c @@ -456,7 +456,7 @@ archive_write_set_format_zip(struct archive *_a) if (a->format_free != NULL) (a->format_free)(a); - zip = (struct zip *) calloc(1, sizeof(*zip)); + zip = calloc(1, sizeof(*zip)); if (zip == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate zip data");