aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/FileCheck/FileCheck.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2018-01-16 08:09:24 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2018-01-16 08:09:24 +0000
commit83e63d96a9a949d3f2fcee6f663c4e4923b9da6f (patch)
tree59be13b941e3e3636605b4a2e606483b6e193f3b /llvm/utils/FileCheck/FileCheck.cpp
parent035dd256d52c0904cf7bc97bcbf156bd4bf008ca (diff)
downloadllvm-83e63d96a9a949d3f2fcee6f663c4e4923b9da6f.zip
llvm-83e63d96a9a949d3f2fcee6f663c4e4923b9da6f.tar.gz
llvm-83e63d96a9a949d3f2fcee6f663c4e4923b9da6f.tar.bz2
[FileCheck] - Fix possible buffer out of bounds access when parsing --check-prefix.
FileCheck tool crashes when trying to parse --check-prefix argument if there is no any data after it. For example test like following would crash if there are no symbols and no EOL mark after `boom`: # REQUIRES: x86 # RUN: <skipped few lines> # RUN: llvm-readobj -t %t | FileCheck %s --check-prefix=boom Patch fixes the issue. Differential revision: https://reviews.llvm.org/D42057 llvm-svn: 322536
Diffstat (limited to 'llvm/utils/FileCheck/FileCheck.cpp')
-rw-r--r--llvm/utils/FileCheck/FileCheck.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp
index 7db9730..7274db6 100644
--- a/llvm/utils/FileCheck/FileCheck.cpp
+++ b/llvm/utils/FileCheck/FileCheck.cpp
@@ -718,6 +718,9 @@ static size_t CheckTypeSize(Check::CheckType Ty) {
}
static Check::CheckType FindCheckType(StringRef Buffer, StringRef Prefix) {
+ if (Buffer.size() <= Prefix.size())
+ return Check::CheckNone;
+
char NextChar = Buffer[Prefix.size()];
// Verify that the : is present after the prefix.