summaryrefslogtreecommitdiff
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-04-11 12:56:32 -0400
committerBrad King <brad.king@kitware.com>2019-04-11 12:56:32 -0400
commitf0948499f6b47a7a856aef3334a8d8a38c1265d5 (patch)
tree4f2ac14d379cf7b4f57c92416593f2ef6e2c54cb /Source/cmSystemTools.cxx
parenta550e2d6e48798d342a5ba7436013c6aa6ce5151 (diff)
downloadcmake-f0948499f6b47a7a856aef3334a8d8a38c1265d5.tar.gz
cmSystemTools: Fix StringToULong to reject negative numbers
Fixes: #19161
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx6
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index d20106128a..212608d489 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -3023,6 +3023,12 @@ bool cmSystemTools::StringToULong(const char* str, unsigned long* value)
{
errno = 0;
char* endp;
+ while (isspace(*str)) {
+ ++str;
+ }
+ if (*str == '-') {
+ return false;
+ }
*value = strtoul(str, &endp, 10);
return (*endp == '\0') && (endp != str) && (errno == 0);
}