diff options
author | Brad King <brad.king@kitware.com> | 2018-03-27 12:18:47 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-03-27 12:46:20 (GMT) |
commit | 75e8af3354c42ce42abb4bece351fe1a8b99d96a (patch) | |
tree | fcd8ba4624e9a449d8e11c35b3c2a29af8f58b13 /Source | |
parent | 6b9172d759b5f00069e7d2c65f1c649d4a3b0a70 (diff) | |
download | CMake-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')
-rw-r--r-- | Source/cmSystemTools.cxx | 13 |
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. |