Hi there,
In publicly accessible set_data function, set_data accept offset and used in ptr.add, which might letting user/developer, using complete safe API to cause a memory issue(here, it could be out of bound access). In rust, we are expecting no memory issue should be caused by merely safe functions.
|
pub fn set_data<T>(&self, offset: usize, data: &[T]) -> Result<(), Error> { |
|
let Some(ptr) = self.allocation.mapped_ptr() else { |
|
return Err(Error::WriteAttemptToUnmappedBuffer); |
|
}; |
|
|
|
let mut ptr = ptr.as_ptr() as *mut T; |
|
unsafe { |
|
ptr = ptr.add(offset); |
|
ptr.copy_from_nonoverlapping(data.as_ptr(), data.len()); |
|
}; |
|
Ok(()) |
It would be great to consider mark function as unsafe or add appropriate check.
Hi there,
In publicly accessible set_data function, set_data accept offset and used in ptr.add, which might letting user/developer, using complete safe API to cause a memory issue(here, it could be out of bound access). In rust, we are expecting no memory issue should be caused by merely safe functions.
vku/src/vma_buffer.rs
Lines 185 to 195 in dc9032c
It would be great to consider mark function as unsafe or add appropriate check.