diff options
author | Filipe Cabecinhas <me@filcab.net> | 2015-11-04 14:53:36 +0000 |
---|---|---|
committer | Filipe Cabecinhas <me@filcab.net> | 2015-11-04 14:53:36 +0000 |
commit | a2b0ac40cfe37cfacb8648814cc74f6e8d2c0ed3 (patch) | |
tree | 38322a4cb55059883f1f155ccea8a797afbfa07a | |
parent | 4305910803a803f655d9ee28ce93cc5acb7760b8 (diff) | |
download | bcm5719-llvm-a2b0ac40cfe37cfacb8648814cc74f6e8d2c0ed3.tar.gz bcm5719-llvm-a2b0ac40cfe37cfacb8648814cc74f6e8d2c0ed3.zip |
Error out when faced with value names containing '\0'
Bug found with afl-fuzz.
llvm-svn: 252048
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 5 | ||||
-rw-r--r-- | llvm/test/Bitcode/Inputs/invalid-name-with-0-byte.bc | bin | 0 -> 1265 bytes | |||
-rw-r--r-- | llvm/test/Bitcode/invalid.test | 5 |
3 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index c874a84e0cb..522f2aa4707 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1749,7 +1749,10 @@ ErrorOr<Value *> BitcodeReader::recordValue(SmallVectorImpl<uint64_t> &Record, return error("Invalid record"); Value *V = ValueList[ValueID]; - V->setName(StringRef(ValueName.data(), ValueName.size())); + StringRef NameStr(ValueName.data(), ValueName.size()); + if (NameStr.find_first_of(0) != StringRef::npos) + return error("Invalid value name"); + V->setName(NameStr); auto *GO = dyn_cast<GlobalObject>(V); if (GO) { if (GO->getComdat() == reinterpret_cast<Comdat *>(1)) { diff --git a/llvm/test/Bitcode/Inputs/invalid-name-with-0-byte.bc b/llvm/test/Bitcode/Inputs/invalid-name-with-0-byte.bc Binary files differnew file mode 100644 index 00000000000..9c6a9158eee --- /dev/null +++ b/llvm/test/Bitcode/Inputs/invalid-name-with-0-byte.bc diff --git a/llvm/test/Bitcode/invalid.test b/llvm/test/Bitcode/invalid.test index 24ccd8bccd5..3425adc8410 100644 --- a/llvm/test/Bitcode/invalid.test +++ b/llvm/test/Bitcode/invalid.test @@ -212,3 +212,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-no-function-block.bc 2>&1 | RUN: FileCheck --check-prefix=NO-FUNCTION-BLOCK %s NO-FUNCTION-BLOCK: Trying to materialize functions before seeing function blocks + +RUN: not llvm-dis -disable-output %p/Inputs/invalid-name-with-0-byte.bc 2>&1 | \ +RUN: FileCheck --check-prefix=NAME-WITH-0 %s + +NAME-WITH-0: Invalid value name |