Skip to content

Commit ab3a2a0

Browse files
committed
Unify copying data from enclave to userspace
1 parent ddb6cc8 commit ab3a2a0

File tree

1 file changed

+3
-7
lines changed
  • library/std/src/sys/sgx/abi/usercalls

1 file changed

+3
-7
lines changed

library/std/src/sys/sgx/abi/usercalls/alloc.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,9 @@ where
225225
/// Copies `val` into freshly allocated space in user memory.
226226
pub fn new_from_enclave(val: &T) -> Self {
227227
unsafe {
228-
let ret = Self::new_uninit_bytes(mem::size_of_val(val));
229-
ptr::copy(
230-
val as *const T as *const u8,
231-
ret.0.as_ptr() as *mut u8,
232-
mem::size_of_val(val),
233-
);
234-
ret
228+
let mut user = Self::new_uninit_bytes(mem::size_of_val(val));
229+
user.copy_from_enclave(val);
230+
user
235231
}
236232
}
237233

0 commit comments

Comments
 (0)