Skip to content

Commit

Permalink
read/elf: handle empty symbol tables (#443)
Browse files Browse the repository at this point in the history
Return `None` from `ElfFile::symbol_table` and
`ElfFile::dynamic_symbol_table` if the tables are empty.
  • Loading branch information
philipc committed Jun 22, 2022
1 parent 3fe732e commit b47d17c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/read/elf/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ where
}

fn symbol_table(&'file self) -> Option<ElfSymbolTable<'data, 'file, Elf, R>> {
if self.symbols.is_empty() {
return None;
}
Some(ElfSymbolTable {
endian: self.endian,
symbols: &self.symbols,
Expand All @@ -279,6 +282,9 @@ where
}

fn dynamic_symbol_table(&'file self) -> Option<ElfSymbolTable<'data, 'file, Elf, R>> {
if self.dynamic_symbols.is_empty() {
return None;
}
Some(ElfSymbolTable {
endian: self.endian,
symbols: &self.dynamic_symbols,
Expand Down

0 comments on commit b47d17c

Please sign in to comment.