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 <kwrobot@kitware.com>
Merge-request: !3948
This commit is contained in:
Craig Scott
2019-10-28 10:50:09 +00:00
committed by Kitware Robot
4 changed files with 37 additions and 2 deletions

View File

@@ -229,7 +229,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]);