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 4305910803
commit a2b0ac40cf
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)) {