1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

Error out when faced with value names containing '\0'

Bug found with afl-fuzz.

llvm-svn: 252048
This commit is contained in:
Filipe Cabecinhas 2015-11-04 14:53:36 +00:00
parent 52c1d43c18
commit e215a5f192
3 changed files with 9 additions and 1 deletions

View File

@ -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)) {

Binary file not shown.

View File

@ -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