Unify copying data from enclave to userspace

This commit is contained in:
Raoul Strackx 2022-03-29 15:31:42 +02:00
parent ddb6cc8524
commit ab3a2a024f

View File

@ -225,13 +225,9 @@ fn new_uninit_bytes(size: usize) -> Self {
/// Copies `val` into freshly allocated space in user memory.
pub fn new_from_enclave(val: &T) -> Self {
unsafe {
let ret = Self::new_uninit_bytes(mem::size_of_val(val));
ptr::copy(
val as *const T as *const u8,
ret.0.as_ptr() as *mut u8,
mem::size_of_val(val),
);
ret
let mut user = Self::new_uninit_bytes(mem::size_of_val(val));
user.copy_from_enclave(val);
user
}
}