From fd0c21eeee5570ba0cc357db90a8337e4d5690ea Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 15 Dec 2016 09:58:41 +0100 Subject: [PATCH] check that the null terminator is defined and not part of a pointer --- src/memory.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/memory.rs b/src/memory.rs index 580372b3da2d..babd9bcb783f 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -536,10 +536,10 @@ impl<'a, 'tcx> Memory<'a, 'tcx> { let offset = ptr.offset as usize; match alloc.bytes[offset..].iter().position(|&c| c == 0) { Some(size) => { - if self.relocations(ptr, size as u64)?.count() != 0 { + if self.relocations(ptr, (size + 1) as u64)?.count() != 0 { return Err(EvalError::ReadPointerAsBytes); } - self.check_defined(ptr, size as u64)?; + self.check_defined(ptr, (size + 1) as u64)?; Ok(&alloc.bytes[offset..offset + size]) }, None => Err(EvalError::UnterminatedCString(ptr)),