mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-28 22:20:37 +00:00
Make sure these error codes are marked as checked
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271013 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c41579b54a
commit
d92a2587d3
@ -98,16 +98,18 @@ Error NameHashTable::load(codeview::StreamReader &Stream) {
|
||||
Signature = H->Signature;
|
||||
HashVersion = H->HashVersion;
|
||||
if (auto EC = Stream.readStreamRef(NamesBuffer, H->ByteSize))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Invalid hash table byte length");
|
||||
return joinErrors(std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Invalid hash table byte length"));
|
||||
|
||||
const support::ulittle32_t *HashCount;
|
||||
if (auto EC = Stream.readObject(HashCount))
|
||||
return EC;
|
||||
|
||||
if (auto EC = Stream.readArray(IDs, *HashCount))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Could not read bucket array");
|
||||
return joinErrors(std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Could not read bucket array"));
|
||||
|
||||
if (Stream.bytesRemaining() < sizeof(support::ulittle32_t))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
|
@ -22,9 +22,10 @@ Error NameMap::load(codeview::StreamReader &Stream) {
|
||||
// This is some sort of weird string-set/hash table encoded in the stream.
|
||||
// It starts with the number of bytes in the table.
|
||||
uint32_t NumberOfBytes;
|
||||
if (Stream.readInteger(NumberOfBytes))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map length");
|
||||
if (auto EC = Stream.readInteger(NumberOfBytes))
|
||||
return joinErrors(std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map length"));
|
||||
if (Stream.bytesRemaining() < NumberOfBytes)
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Invalid name map length");
|
||||
@ -36,31 +37,35 @@ Error NameMap::load(codeview::StreamReader &Stream) {
|
||||
// This appears to be equivalent to the total number of strings *actually*
|
||||
// in the name table.
|
||||
uint32_t HashSize;
|
||||
if (Stream.readInteger(HashSize))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map hash size");
|
||||
if (auto EC = Stream.readInteger(HashSize))
|
||||
return joinErrors(std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map hash size"));
|
||||
|
||||
// This appears to be an upper bound on the number of strings in the name
|
||||
// table.
|
||||
uint32_t MaxNumberOfStrings;
|
||||
if (Stream.readInteger(MaxNumberOfStrings))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map max strings");
|
||||
if (auto EC = Stream.readInteger(MaxNumberOfStrings))
|
||||
return joinErrors(std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map max strings"));
|
||||
|
||||
// This appears to be a hash table which uses bitfields to determine whether
|
||||
// or not a bucket is 'present'.
|
||||
uint32_t NumPresentWords;
|
||||
if (Stream.readInteger(NumPresentWords))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map num words");
|
||||
if (auto EC = Stream.readInteger(NumPresentWords))
|
||||
return joinErrors(std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map num words"));
|
||||
|
||||
// Store all the 'present' bits in a vector for later processing.
|
||||
SmallVector<uint32_t, 1> PresentWords;
|
||||
for (uint32_t I = 0; I != NumPresentWords; ++I) {
|
||||
uint32_t Word;
|
||||
if (Stream.readInteger(Word))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map word");
|
||||
if (auto EC = Stream.readInteger(Word))
|
||||
return joinErrors(std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map word"));
|
||||
|
||||
PresentWords.push_back(Word);
|
||||
}
|
||||
@ -68,17 +73,20 @@ Error NameMap::load(codeview::StreamReader &Stream) {
|
||||
// This appears to be a hash table which uses bitfields to determine whether
|
||||
// or not a bucket is 'deleted'.
|
||||
uint32_t NumDeletedWords;
|
||||
if (Stream.readInteger(NumDeletedWords))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map num deleted words");
|
||||
if (auto EC = Stream.readInteger(NumDeletedWords))
|
||||
return joinErrors(
|
||||
std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map num deleted words"));
|
||||
|
||||
// Store all the 'deleted' bits in a vector for later processing.
|
||||
SmallVector<uint32_t, 1> DeletedWords;
|
||||
for (uint32_t I = 0; I != NumDeletedWords; ++I) {
|
||||
uint32_t Word;
|
||||
if (Stream.readInteger(Word))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map deleted word");
|
||||
if (auto EC = Stream.readInteger(Word))
|
||||
return joinErrors(std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map deleted word"));
|
||||
|
||||
DeletedWords.push_back(Word);
|
||||
}
|
||||
@ -99,15 +107,17 @@ Error NameMap::load(codeview::StreamReader &Stream) {
|
||||
// This appears to be an offset relative to the start of the strings.
|
||||
// It tells us where the null-terminated string begins.
|
||||
uint32_t NameOffset;
|
||||
if (Stream.readInteger(NameOffset))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map name offset");
|
||||
if (auto EC = Stream.readInteger(NameOffset))
|
||||
return joinErrors(std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map name offset"));
|
||||
|
||||
// This appears to be a stream number into the stream directory.
|
||||
uint32_t NameIndex;
|
||||
if (Stream.readInteger(NameIndex))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map name index");
|
||||
if (auto EC = Stream.readInteger(NameIndex))
|
||||
return joinErrors(std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map name index"));
|
||||
|
||||
// Compute the offset of the start of the string relative to the stream.
|
||||
uint32_t StringOffset = StringsOffset + NameOffset;
|
||||
@ -115,9 +125,10 @@ Error NameMap::load(codeview::StreamReader &Stream) {
|
||||
// Pump out our c-string from the stream.
|
||||
StringRef Str;
|
||||
Stream.setOffset(StringOffset);
|
||||
if (Stream.readZeroString(Str))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map name");
|
||||
if (auto EC = Stream.readZeroString(Str))
|
||||
return joinErrors(std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Expected name map name"));
|
||||
|
||||
Stream.setOffset(OldOffset);
|
||||
// Add this to a string-map from name to stream number.
|
||||
|
@ -106,15 +106,17 @@ Error PublicsStream::reload() {
|
||||
"Invalid HR array size.");
|
||||
uint32_t NumHashRecords = HashHdr->HrSize / sizeof(PSHashRecord);
|
||||
if (auto EC = Reader.readArray(HashRecords, NumHashRecords))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Could not read an HR array");
|
||||
return joinErrors(std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Could not read an HR array"));
|
||||
|
||||
// A bitmap of a fixed length follows.
|
||||
size_t BitmapSizeInBits = alignTo(IPHR_HASH + 1, 32);
|
||||
uint32_t NumBitmapEntries = BitmapSizeInBits / 8;
|
||||
if (auto EC = Reader.readBytes(NumBitmapEntries, Bitmap))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Could not read a bitmap.");
|
||||
return joinErrors(std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Could not read a bitmap."));
|
||||
for (uint8_t B : Bitmap)
|
||||
NumBuckets += countPopulation(B);
|
||||
|
||||
@ -125,24 +127,28 @@ Error PublicsStream::reload() {
|
||||
|
||||
// Hash buckets follow.
|
||||
if (auto EC = Reader.readArray(HashBuckets, NumBuckets))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Hash buckets corrupted.");
|
||||
return joinErrors(std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Hash buckets corrupted."));
|
||||
|
||||
// Something called "address map" follows.
|
||||
uint32_t NumAddressMapEntries = Header->AddrMap / sizeof(uint32_t);
|
||||
if (auto EC = Reader.readArray(AddressMap, NumAddressMapEntries))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Could not read an address map.");
|
||||
return joinErrors(std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Could not read an address map."));
|
||||
|
||||
// Something called "thunk map" follows.
|
||||
if (auto EC = Reader.readArray(ThunkMap, Header->NumThunks))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Could not read a thunk map.");
|
||||
return joinErrors(std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Could not read a thunk map."));
|
||||
|
||||
// Something called "section map" follows.
|
||||
if (auto EC = Reader.readArray(SectionOffsets, Header->NumSections))
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Could not read a section map.");
|
||||
return joinErrors(std::move(EC),
|
||||
make_error<RawError>(raw_error_code::corrupt_file,
|
||||
"Could not read a section map."));
|
||||
|
||||
if (Reader.bytesRemaining() > 0)
|
||||
return make_error<RawError>(raw_error_code::corrupt_file,
|
||||
|
Loading…
Reference in New Issue
Block a user