diff options
author | pommicket <pommicket@gmail.com> | 2022-11-06 22:53:44 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-11-06 22:53:44 -0500 |
commit | 2c068ecc21a972aa00f2871a4405e31547bf765a (patch) | |
tree | 94442139f33b5c33482fae6007298e6526dc5dce /src/elf.rs | |
parent | 000f57e11cf3272951cd3463f5d8bb82bc8e3903 (diff) |
overflow checking
Diffstat (limited to 'src/elf.rs')
-rw-r--r-- | src/elf.rs | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -109,8 +109,8 @@ impl Default for Ehdr32 { } impl Ehdr32 { - pub fn size_of() -> usize { - mem::size_of::<Self>() + pub fn size_of() -> u8 { + mem::size_of::<Self>() as u8 } } @@ -537,7 +537,8 @@ impl Reader for Reader32LE { let name = bytes_to_string(bytes)?; if name == ".strtab" { - strtab_idx = Some(s_idx as u16); + // since shdrs.len() == ehdr.shnum, this should never panic. + strtab_idx = Some(s_idx.try_into().unwrap()); } } |