From c0aa4f78c28867e1469060bf5443a691d43038da Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 18 Apr 2020 18:04:46 +0800 Subject: [PATCH] dyld: more fine grained errors --- libdyld/src/lib.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libdyld/src/lib.rs b/libdyld/src/lib.rs index f0400215..fbd59943 100644 --- a/libdyld/src/lib.rs +++ b/libdyld/src/lib.rs @@ -233,9 +233,11 @@ impl<'a> Library<'a> { match phdr.p_type { PT_LOAD => { - if (phdr.p_vaddr + phdr.p_filesz) as usize > image.len() || - (phdr.p_offset + phdr.p_filesz) as usize > data.len() { - return Err("program header requests an out of bounds load")? + if (phdr.p_vaddr + phdr.p_filesz) as usize > image.len() { + return Err("program header requests an out of bounds load (in image)")? + } + if (phdr.p_offset + phdr.p_filesz) as usize > data.len() { + return Err("program header requests an out of bounds load (in data)")? } let dst = image.get_mut(phdr.p_vaddr as usize.. (phdr.p_vaddr + phdr.p_filesz) as usize)