Skip to content

Commit

Permalink
td-lader/src/elf64.rs: Fix Relocs iteration may infinite loop #263
Browse files Browse the repository at this point in the history
Signed-off-by: haowei <WeiX.Hao@intel.com>
  • Loading branch information
haowqs authored and jyao1 committed May 15, 2022
1 parent 64796e6 commit 0e08c3e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions td-loader/src/elf64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,11 @@ impl<'a> Iterator for Relocs<'a> {
if self.index >= self.relacount {
return None;
}

if self.relaent == 0 {
return None;
}

let offset = self.index * self.relaent;
self.entries.len().checked_sub(offset)?;
let current_bytes = &self.entries[offset..];
Expand Down

0 comments on commit 0e08c3e

Please sign in to comment.