Struct libcryptsetup_rs::SafeOwnedMemZero
source · pub struct SafeOwnedMemZero(/* private fields */);
Expand description
Handle for zeroing owned memory. “Owned” in this context refers to memory
that has been allocated and stored in some kind of char **
argument
in the context of C FFI. This means that the memory has been allocated
by standard C allocators and needs to be cleaned up by the caller.
In the context of Rust, we would consider this owned by the current scope.
SECURITY WARNING
Any pointer used with this must point to memory allocated by libc::malloc
or any other function compatible with libc::free
. If it has not been,
you could cause memory corruption and security problems.
Implementations§
source§impl SafeOwnedMemZero
impl SafeOwnedMemZero
sourcepub unsafe fn from_ptr(ptr: *mut c_void, size: usize) -> Self
pub unsafe fn from_ptr(ptr: *mut c_void, size: usize) -> Self
Construct a safe memory handle from a pointer and a size.
Safety
The pointer must point to memory allocated by libc::malloc
or something
compatible with libc::free
. See the struct-level security warning for more
information. The size
argument also must match the length of the
allocated block or memory corruption could occur.
Trait Implementations§
source§impl AsMut<[u8]> for SafeOwnedMemZero
impl AsMut<[u8]> for SafeOwnedMemZero
source§impl AsRef<[u8]> for SafeOwnedMemZero
impl AsRef<[u8]> for SafeOwnedMemZero
source§impl Drop for SafeOwnedMemZero
impl Drop for SafeOwnedMemZero
source§impl SafeMemzero for SafeOwnedMemZero
impl SafeMemzero for SafeOwnedMemZero
source§fn safe_memzero(&mut self)
fn safe_memzero(&mut self)
Drop
implementation.