Skip to content

Commit fd0c21e

Browse files
committed
check that the null terminator is defined and not part of a pointer
1 parent 2420360 commit fd0c21e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: src/memory.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,10 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
536536
let offset = ptr.offset as usize;
537537
match alloc.bytes[offset..].iter().position(|&c| c == 0) {
538538
Some(size) => {
539-
if self.relocations(ptr, size as u64)?.count() != 0 {
539+
if self.relocations(ptr, (size + 1) as u64)?.count() != 0 {
540540
return Err(EvalError::ReadPointerAsBytes);
541541
}
542-
self.check_defined(ptr, size as u64)?;
542+
self.check_defined(ptr, (size + 1) as u64)?;
543543
Ok(&alloc.bytes[offset..offset + size])
544544
},
545545
None => Err(EvalError::UnterminatedCString(ptr)),

0 commit comments

Comments
 (0)