[llvm] r252048 - Error out when faced with value names containing '\0'
Filipe Cabecinhas via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 4 06:53:37 PST 2015
Author: filcab
Date: Wed Nov 4 08:53:36 2015
New Revision: 252048
URL: http://llvm.org/viewvc/llvm-project?rev=252048&view=rev
Log:
Error out when faced with value names containing '\0'
Bug found with afl-fuzz.
Added:
llvm/trunk/test/Bitcode/Inputs/invalid-name-with-0-byte.bc
Modified:
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/trunk/test/Bitcode/invalid.test
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=252048&r1=252047&r2=252048&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Wed Nov 4 08:53:36 2015
@@ -1749,7 +1749,10 @@ ErrorOr<Value *> BitcodeReader::recordVa
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)) {
Added: llvm/trunk/test/Bitcode/Inputs/invalid-name-with-0-byte.bc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/Inputs/invalid-name-with-0-byte.bc?rev=252048&view=auto
==============================================================================
Binary files llvm/trunk/test/Bitcode/Inputs/invalid-name-with-0-byte.bc (added) and llvm/trunk/test/Bitcode/Inputs/invalid-name-with-0-byte.bc Wed Nov 4 08:53:36 2015 differ
Modified: llvm/trunk/test/Bitcode/invalid.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/invalid.test?rev=252048&r1=252047&r2=252048&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/invalid.test (original)
+++ llvm/trunk/test/Bitcode/invalid.test Wed Nov 4 08:53:36 2015
@@ -212,3 +212,8 @@ RUN: not llvm-dis -disable-output %p/Inp
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
More information about the llvm-commits
mailing list