summaryrefslogtreecommitdiffstats
path: root/Source/CTest
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-01-17 14:56:00 (GMT)
committerBrad King <brad.king@kitware.com>2024-01-17 15:17:06 (GMT)
commitd9d9326e1438855efd5089f76943ce7b31d1f2ad (patch)
treed11a380a2e210f4bf9f6bc47742fc00e64ca555e /Source/CTest
parent14abdc8e2b7d49cf74354894f3bd8cbf35b3bf85 (diff)
downloadCMake-d9d9326e1438855efd5089f76943ce7b31d1f2ad.zip
CMake-d9d9326e1438855efd5089f76943ce7b31d1f2ad.tar.gz
CMake-d9d9326e1438855efd5089f76943ce7b31d1f2ad.tar.bz2
Source: Avoid out-of-range inputs to std::isspace()
`isspace` takes `int` but documents that the value must be representable by `unsigned char`, or be EOF. Use a wrapper to cast to `unsigned char` to avoid sign extension while converting to `int`. This generalizes the fix from commit 5e8c176e2a (cmExecuteProcessCommand: Cast c to unsigned char before cast to int, 2024-01-05) to other `isspace` call sites. This was detected by assertions in the MSVC standard library while processing UTF-8 text. Issue: #25561
Diffstat (limited to 'Source/CTest')
-rw-r--r--Source/CTest/cmCTestGIT.cxx9
1 files changed, 4 insertions, 5 deletions
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx
index 984c837..99c5a2b 100644
--- a/Source/CTest/cmCTestGIT.cxx
+++ b/Source/CTest/cmCTestGIT.cxx
@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestGIT.h"
-#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <ctime>
@@ -414,14 +413,14 @@ protected:
const char* ConsumeSpace(const char* c)
{
- while (*c && isspace(*c)) {
+ while (*c && cmIsSpace(*c)) {
++c;
}
return c;
}
const char* ConsumeField(const char* c)
{
- while (*c && !isspace(*c)) {
+ while (*c && !cmIsSpace(*c)) {
++c;
}
return c;
@@ -481,7 +480,7 @@ private:
{
// Person Name <person@domain.com> 1234567890 +0000
const char* c = str;
- while (*c && isspace(*c)) {
+ while (*c && cmIsSpace(*c)) {
++c;
}
@@ -490,7 +489,7 @@ private:
++c;
}
const char* name_last = c;
- while (name_last != name_first && isspace(*(name_last - 1))) {
+ while (name_last != name_first && cmIsSpace(*(name_last - 1))) {
--name_last;
}
person.Name.assign(name_first, name_last - name_first);