about summary refs log tree commit diff homepage
path: root/tools
diff options
context:
space:
mode:
authorFrank Busse <bb0xfb@gmail.com>2018-05-17 23:12:24 +0100
committerCristian Cadar <c.cadar@imperial.ac.uk>2018-06-29 11:33:11 +0100
commit4c15d279e4d92b204275e973f2cedb76f63b0ac3 (patch)
treee52f242dba1b04b6f12f8cea19773730c050520e /tools
parent2ef1fa8fc2afd74236180e23ec77f6948e5295d6 (diff)
downloadklee-4c15d279e4d92b204275e973f2cedb76f63b0ac3.tar.gz
fix out of range access in KleeHandler::getKTestFilesInDir
Diffstat (limited to 'tools')
-rw-r--r--tools/klee/main.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp
index ab9dfe28..1178c9cf 100644
--- a/tools/klee/main.cpp
+++ b/tools/klee/main.cpp
@@ -546,11 +546,11 @@ void KleeHandler::getKTestFilesInDir(std::string directoryPath,
 #else
   std::error_code ec;
 #endif
-  for (llvm::sys::fs::directory_iterator i(directoryPath, ec), e; i != e && !ec;
-       i.increment(ec)) {
-    std::string f = (*i).path();
-    if (f.substr(f.size()-6,f.size()) == ".ktest") {
-          results.push_back(f);
+  llvm::sys::fs::directory_iterator i(directoryPath, ec), e;
+  for (; i != e && !ec; i.increment(ec)) {
+    auto f = i->path();
+    if (f.size() >= 6 && f.substr(f.size()-6,f.size()) == ".ktest") {
+      results.push_back(f);
     }
   }