mirror of
https://github.com/gbdev/rgbds.git
synced 2026-03-25 22:33:03 +00:00
Fix some rgblink object file input bugs found via fuzzing with AFL++ (#1867)
- ID numbers (for fstack nodes, sections, symbols, patches, etc) might be too large for their associated collection - Enum values might be invalid - Bank values might be out of range for their section types
This commit is contained in:
@@ -119,6 +119,15 @@ static std::optional<size_t> getPlacement(Section const §ion, MemoryLocation
|
||||
SectionTypeInfo const &typeInfo = sectionTypeInfo[section.type];
|
||||
|
||||
for (;;) {
|
||||
if (location.bank < typeInfo.firstBank
|
||||
|| location.bank >= memory[section.type].size() + typeInfo.firstBank) {
|
||||
fatal(
|
||||
"Invalid bank for %s section: 0x%02x",
|
||||
sectionTypeInfo[section.type].name.c_str(),
|
||||
location.bank
|
||||
);
|
||||
}
|
||||
|
||||
// Switch to the beginning of the next bank
|
||||
std::deque<FreeSpace> &bankMem = memory[section.type][location.bank - typeInfo.firstBank];
|
||||
size_t spaceIdx = 0;
|
||||
|
||||
Reference in New Issue
Block a user