diff options
author | Sean McBride <sean@rogue-research.com> | 2021-10-21 16:35:57 (GMT) |
---|---|---|
committer | Sean McBride <sean@rogue-research.com> | 2021-10-25 22:23:13 (GMT) |
commit | 5ba6e8ac59333aa574d5963332e3ef0f4c4d3514 (patch) | |
tree | d796f695e10d5ec20508cb04f4c8b3c2a6c0d742 /Source/cmProjectCommand.cxx | |
parent | 0ce50dd78f68b697e1ab29d52d733b87c5bfb67d (diff) | |
download | CMake-5ba6e8ac59333aa574d5963332e3ef0f4c4d3514.zip CMake-5ba6e8ac59333aa574d5963332e3ef0f4c4d3514.tar.gz CMake-5ba6e8ac59333aa574d5963332e3ef0f4c4d3514.tar.bz2 |
Source: Replace most calls to sprintf with snprintf
Diffstat (limited to 'Source/cmProjectCommand.cxx')
-rw-r--r-- | Source/cmProjectCommand.cxx | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 20fcdbe..04d99c9 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -235,14 +235,15 @@ 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 + 2]; + constexpr size_t maxIntLength = + std::numeric_limits<unsigned>::digits10 + 2; + char vb[MAX_VERSION_COMPONENTS][maxIntLength]; 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]); for (auto i = 0u; i < MAX_VERSION_COMPONENTS; ++i) { if (int(i) < vc) { - std::sprintf(vb[i], "%u", v[i]); + std::snprintf(vb[i], maxIntLength, "%u", v[i]); version_string += &"."[std::size_t(i == 0)]; version_string += vb[i]; version_components[i] = vb[i]; |