// Initializes this->SectionHeaders.
Error DbiStream::initializeSectionHeadersData() {
uint32_t StreamNum = getDebugStreamIndex(DbgHeaderType::SectionHdr);
+ if (StreamNum >= Pdb.getNumStreams())
+ return make_error<RawError>(raw_error_code::no_stream);
+
SectionHeaderStream.reset(new MappedBlockStream(
llvm::make_unique<IndexedStreamData>(StreamNum, Pdb), Pdb));
// Initializes this->Fpos.
Error DbiStream::initializeFpoRecords() {
uint32_t StreamNum = getDebugStreamIndex(DbgHeaderType::NewFPO);
+ if (StreamNum >= Pdb.getNumStreams())
+ return make_error<RawError>(raw_error_code::no_stream);
+
FpoStream.reset(new MappedBlockStream(
llvm::make_unique<IndexedStreamData>(StreamNum, Pdb), Pdb));
if (NameStreamIndex == 0)
return make_error<RawError>(raw_error_code::no_stream);
+ if (NameStreamIndex >= getNumStreams())
+ return make_error<RawError>(raw_error_code::no_stream);
+
auto SD = llvm::make_unique<IndexedStreamData>(NameStreamIndex, *this);
auto S = llvm::make_unique<MappedBlockStream>(std::move(SD), *this);
codeview::StreamReader Reader(*S);
return EC;
// Hash indices, hash values, etc come from the hash stream.
+ if (Header->HashStreamIndex >= Pdb.getNumStreams())
+ return make_error<RawError>(raw_error_code::corrupt_file,
+ "Invalid TPI hash stream index.");
+
HashStream.reset(new MappedBlockStream(
llvm::make_unique<IndexedStreamData>(Header->HashStreamIndex, Pdb), Pdb));
codeview::StreamReader HSR(*HashStream);
uint32_t StreamCount = File.getNumStreams();
StringRef DumpStreamStr = opts::DumpStreamDataIdx;
uint32_t DumpStreamNum;
- if (DumpStreamStr.getAsInteger(/*Radix=*/0U, DumpStreamNum) ||
- DumpStreamNum >= StreamCount)
+ if (DumpStreamStr.getAsInteger(/*Radix=*/0U, DumpStreamNum))
return Error::success();
+ if (DumpStreamNum >= StreamCount)
+ return make_error<RawError>(raw_error_code::no_stream);
+
MappedBlockStream S(llvm::make_unique<IndexedStreamData>(DumpStreamNum, File),
File);
codeview::StreamReader R(S);
InfoStream &IS = InfoS.get();
uint32_t NameStreamIndex = IS.getNamedStreamIndex(opts::DumpStreamDataName);
+ if (NameStreamIndex == 0 || NameStreamIndex >= File.getNumStreams())
+ return make_error<RawError>(raw_error_code::no_stream);
if (NameStreamIndex != 0) {
std::string Name("Stream '");
return true;
if (opts::DumpIpiRecordBytes)
return true;
+ if (opts::DumpSectionHeaders)
+ return true;
if (opts::DumpSectionContribs)
return true;
if (opts::DumpSectionMap)