summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
diff options
context:
space:
mode:
authorStefan Granitz <stefan.graenitz@gmail.com>2019-02-15 16:42:29 +0000
committerStefan Granitz <stefan.graenitz@gmail.com>2019-02-15 16:42:29 +0000
commit42a9da7b355034159e61fdcbeea7c7efb5bff5ed (patch)
tree141070939a1fbe7f62dfa06cebc45188e68a95f8 /lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
parent8a2b543a133340377e8cc92ee8860d60ee93d80c (diff)
downloadbcm5719-llvm-42a9da7b355034159e61fdcbeea7c7efb5bff5ed.tar.gz
bcm5719-llvm-42a9da7b355034159e61fdcbeea7c7efb5bff5ed.zip
Fix potential UB when target_file directory is null
Summary: As seen in a crash report, the C-string returned for the directory component of `target_file` can null. It should not be assigned to `std::string` directly as this is undefined behavior. Reviewers: jingham Reviewed By: jingham Subscribers: jdoerfert, lldb-commits, #lldb Differential Revision: https://reviews.llvm.org/D57964 llvm-svn: 354145
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 93497f13d7d..d1cd3ae5681 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -2781,6 +2781,11 @@ bool ScriptInterpreterPython::LoadScriptingModule(
basename = pathname; // not a filename, probably a package of some sort,
// let it go through
} else if (is_directory(st) || is_regular_file(st)) {
+ if (target_file.GetDirectory().IsEmpty()) {
+ error.SetErrorString("invalid directory name");
+ return false;
+ }
+
std::string directory = target_file.GetDirectory().GetCString();
replace_all(directory, "\\", "\\\\");
replace_all(directory, "'", "\\'");
OpenPOWER on IntegriCloud