This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  cdcc173e236963ad598b098d2d807d0489aa3d42 (commit)
       via  82cdb26c93b595e3791818cc8f24dfc6935eb8a8 (commit)
       via  15a0b0d04660fdec8c231ec4d1054ff5f5274610 (commit)
      from  e03b677e703f84c9d1a2875083d1290db16eb4ad (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cdcc173e236963ad598b098d2d807d0489aa3d42
commit cdcc173e236963ad598b098d2d807d0489aa3d42
Merge: e03b677e70 82cdb26c93
Author:     Craig Scott <craig.sc...@crascit.com>
AuthorDate: Mon Oct 28 10:50:09 2019 +0000
Commit:     Kitware Robot <kwro...@kitware.com>
CommitDate: Mon Oct 28 06:50:22 2019 -0400

    Merge topic 'project-version-buffer-overflow'
    
    82cdb26c93 project: Fix potential buffer write-past-end for version 
components
    15a0b0d046 Help: math() expressions must be representable as signed 64-bit
    
    Acked-by: Kitware Robot <kwro...@kitware.com>
    Merge-request: !3948


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=82cdb26c93b595e3791818cc8f24dfc6935eb8a8
commit 82cdb26c93b595e3791818cc8f24dfc6935eb8a8
Author:     Craig Scott <craig.sc...@crascit.com>
AuthorDate: Sat Oct 26 16:30:22 2019 +1100
Commit:     Craig Scott <craig.sc...@crascit.com>
CommitDate: Sat Oct 26 17:50:24 2019 +1100

    project: Fix potential buffer write-past-end for version components
    
    This fixes two errors: not accounting for the trailing null and a
    misunderstanding of what std::numeric_limits::digits10 means.

diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index eb59b4f65a..7bb5209da0 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -224,7 +224,8 @@ bool cmProjectCommand(std::vector<std::string> const& args,
     std::array<std::string, MAX_VERSION_COMPONENTS> version_components;
 
     if (cmp0096 == cmPolicies::OLD || cmp0096 == cmPolicies::WARN) {
-      char vb[MAX_VERSION_COMPONENTS][std::numeric_limits<unsigned>::digits10];
+      char vb[MAX_VERSION_COMPONENTS]
+             [std::numeric_limits<unsigned>::digits10 + 2];
       unsigned v[MAX_VERSION_COMPONENTS] = { 0, 0, 0, 0 };
       const int vc = std::sscanf(version.c_str(), "%u.%u.%u.%u", &v[0], &v[1],
                                  &v[2], &v[3]);
diff --git a/Tests/RunCMake/project/RunCMakeTest.cmake 
b/Tests/RunCMake/project/RunCMakeTest.cmake
index 8f43a51803..69146993bd 100644
--- a/Tests/RunCMake/project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/project/RunCMakeTest.cmake
@@ -22,6 +22,7 @@ run_cmake(VersionInvalid)
 run_cmake(VersionMissingLanguages)
 run_cmake(VersionMissingValueOkay)
 run_cmake(VersionTwice)
+run_cmake(VersionMax)
 
 run_cmake(CMP0048-OLD)
 run_cmake(CMP0048-OLD-VERSION)
diff --git a/Tests/RunCMake/project/VersionMax.cmake 
b/Tests/RunCMake/project/VersionMax.cmake
new file mode 100644
index 0000000000..e955364384
--- /dev/null
+++ b/Tests/RunCMake/project/VersionMax.cmake
@@ -0,0 +1,32 @@
+cmake_policy(SET CMP0048 NEW)
+cmake_policy(SET CMP0096 OLD)
+
+enable_language(C)
+include(CheckTypeSize)
+check_type_size(unsigned __sizeOfUnsigned BUILTIN_TYPES_ONLY LANGUAGE C)
+
+# We can't use math() to compute this because it only supports up to
+# 64-bit signed integers, so hard-code the types we expect to encounter
+if(__sizeOfUnsigned EQUAL 0)
+  message(STATUS "Multi-architecture build, skipping project version check")
+  return()
+elseif(__sizeOfUnsigned EQUAL 4)
+  set(maxVal 4294967295)
+elseif(__sizeOfUnsigned EQUAL 8)
+  set(maxVal 18446744073709551615)
+else()
+  message(FATAL_ERROR
+    "Test needs to be updated for unsigned integer size ${__sizeOfUnsigned}")
+endif()
+
+# The real value of this test is when an address sanitizer is enabled.
+# It catches situations where the size of the buffer used to compute or
+# hold the version components as strings is too small.
+project(ProjectA VERSION ${maxVal}.${maxVal}.${maxVal}.${maxVal} LANGUAGES 
NONE)
+
+if(NOT ${PROJECT_VERSION_MAJOR} EQUAL ${maxVal})
+  message(FATAL_ERROR "Project version number parsing failed round trip.\n"
+    "Expected: ${maxVal}\n"
+    "Computed: ${PROJECT_VERSION_MAJOR}"
+  )
+endif()

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=15a0b0d04660fdec8c231ec4d1054ff5f5274610
commit 15a0b0d04660fdec8c231ec4d1054ff5f5274610
Author:     Craig Scott <craig.sc...@crascit.com>
AuthorDate: Sat Oct 26 16:20:14 2019 +1100
Commit:     Craig Scott <craig.sc...@crascit.com>
CommitDate: Sat Oct 26 17:47:03 2019 +1100

    Help: math() expressions must be representable as signed 64-bit

diff --git a/Help/command/math.rst b/Help/command/math.rst
index 3cbe719e56..ddb1ec63cf 100644
--- a/Help/command/math.rst
+++ b/Help/command/math.rst
@@ -8,7 +8,8 @@ Evaluate a mathematical expression.
   math(EXPR <variable> "<expression>" [OUTPUT_FORMAT <format>])
 
 Evaluates a mathematical ``<expression>`` and sets ``<variable>`` to the
-resulting value.
+resulting value.  The result of the expression must be representable as a
+64-bit signed integer.
 
 The mathematical expression must be given as a string (i.e. enclosed in
 double quotation marks). An example is ``"5 * (10 + 13)"``.

-----------------------------------------------------------------------

Summary of changes:
 Help/command/math.rst                     |  3 ++-
 Source/cmProjectCommand.cxx               |  3 ++-
 Tests/RunCMake/project/RunCMakeTest.cmake |  1 +
 Tests/RunCMake/project/VersionMax.cmake   | 32 +++++++++++++++++++++++++++++++
 4 files changed, 37 insertions(+), 2 deletions(-)
 create mode 100644 Tests/RunCMake/project/VersionMax.cmake


hooks/post-receive
-- 
CMake
_______________________________________________
Cmake-commits mailing list
Cmake-commits@cmake.org
https://cmake.org/mailman/listinfo/cmake-commits

Reply via email to