diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2022-04-28 19:39:28 +0200 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2022-04-28 19:39:28 +0200 |
commit | 15f13f74b67a8d46d8429d7f53128a167c84eebd (patch) | |
tree | ff96a16293d88f822859fc79bc45c58d33a56f85 | |
parent | b368a18a914a44fd74896b7b1ac7a2530b2bdcb3 (diff) | |
download | elfload-15f13f74b67a8d46d8429d7f53128a167c84eebd.tar.gz elfload-15f13f74b67a8d46d8429d7f53128a167c84eebd.zip |
check mul/add when indexing into phdr
-rw-r--r-- | src/lib.rs | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -242,7 +242,8 @@ impl Elf<'_> { let phoff = usize::try_from(phoff).expect("phoff too large!"); for ph in 0..phnum { - let pos = phoff + usize::from(ph * phentsize); + let off = ph.checked_mul(phentsize).map(usize::from).expect("phdr offset overflowed"); + let pos = phoff.checked_add(off).expect("phdr position overflowed"); r.set_pos(pos); // We only care about load segments. |