Skip to content

Commit

Permalink
Fix crash when relocation section is malformed
Browse files Browse the repository at this point in the history
Found by a fuzzer

Signed-off-by: Dave Thaler <[email protected]>
  • Loading branch information
dthaler authored and elazarg committed Nov 23, 2024
1 parent 4fae457 commit 22625ba
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/asm_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ static void append_subprograms(raw_program& prog, const vector<raw_program>& pro

auto [symbol_name, section_index] =
get_symbol_name_and_section_index(symbols, reloc.relocation_entry_index);
if (section_index >= reader.sections.size()) {
throw UnmarshalError("Invalid section index " + std::to_string(section_index) + " at source offset " +
std::to_string(reloc.source_offset));
}
ELFIO::section& subprogram_section = *reader.sections[section_index];
auto subprogram = read_subprogram(subprogram_section, symbols, symbol_name);
prog.prog.insert(prog.prog.end(), subprogram.begin(), subprogram.end());
Expand Down

0 comments on commit 22625ba

Please sign in to comment.