Hello, thank you for your contribution in this work. I'm scanning rust project for unsound problem.
I notice the following code.
pub struct IOBuff {
pub addr: u64,
pub size: usize,
}
impl IOBuff {
....................................
pub fn Buf(&self) -> &'static mut [u8] {
let ptr = self.addr as *mut u8;
let toSlice = unsafe { slice::from_raw_parts_mut(ptr, self.size) };
return toSlice;
}
......................................
}
considering IOBuff is a pub struct and addr is a pub field, I;m not sure whether user can directlt create and assign addr field. And with the direct call to slice::from_raw_parts_mut(ptr, self.size) which may result in UB. I am not sure whether user can direct call the Buf method, if it is not for external using, maybe we should mark it as unsafe or pub(crate)? I brought this up for security reasons, so please don't mind if this is a false report.
Hello, thank you for your contribution in this work. I'm scanning rust project for unsound problem.
I notice the following code.
considering
IOBuffis apubstruct andaddris apubfield, I;m not sure whether user can directlt create and assignaddrfield. And with the direct call toslice::from_raw_parts_mut(ptr, self.size)which may result in UB. I am not sure whether user can direct call theBufmethod, if it is not for external using, maybe we should mark it asunsafeorpub(crate)? I brought this up for security reasons, so please don't mind if this is a false report.