summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-03-27 12:18:47 (GMT)
committerBrad King <brad.king@kitware.com>2018-03-27 12:46:20 (GMT)
commit75e8af3354c42ce42abb4bece351fe1a8b99d96a (patch)
treefcd8ba4624e9a449d8e11c35b3c2a29af8f58b13 /Source/cmSystemTools.cxx
parent6b9172d759b5f00069e7d2c65f1c649d4a3b0a70 (diff)
downloadCMake-75e8af3354c42ce42abb4bece351fe1a8b99d96a.zip
CMake-75e8af3354c42ce42abb4bece351fe1a8b99d96a.tar.gz
CMake-75e8af3354c42ce42abb4bece351fe1a8b99d96a.tar.bz2
cmSystemTools: Fix ParseArguments out-of-bounds read
When checking for a Windows-style leading path, do not read past the null terminator. Issue: #17854
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx13
1 files changed, 7 insertions, 6 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 88cfe81..eeb73c3 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -550,12 +550,13 @@ std::vector<std::string> cmSystemTools::ParseArguments(const char* command)
bool win_path = false;
- if ((command[0] != '/' && command[1] == ':' && command[2] == '\\') ||
- (command[0] == '\"' && command[1] != '/' && command[2] == ':' &&
- command[3] == '\\') ||
- (command[0] == '\'' && command[1] != '/' && command[2] == ':' &&
- command[3] == '\\') ||
- (command[0] == '\\' && command[1] == '\\')) {
+ if (command[0] && command[1] &&
+ ((command[0] != '/' && command[1] == ':' && command[2] == '\\') ||
+ (command[0] == '\"' && command[1] != '/' && command[2] == ':' &&
+ command[3] == '\\') ||
+ (command[0] == '\'' && command[1] != '/' && command[2] == ':' &&
+ command[3] == '\\') ||
+ (command[0] == '\\' && command[1] == '\\'))) {
win_path = true;
}
// Split the command into an argv array.