about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorRaoul Strackx <raoul.strackx@fortanix.com>2022-03-29 15:31:42 +0200
committerRaoul Strackx <raoul.strackx@fortanix.com>2022-06-15 10:16:48 +0200
commitab3a2a024fb58d5ad3e893f1d5694468b187b2d3 (patch)
tree74ce1323ffd7f67b2588d2f40e27260205e86e8d /library/std/src/sys
parentddb6cc85243ac4761fbc32a407b10216544fe57b (diff)
downloadrust-ab3a2a024fb58d5ad3e893f1d5694468b187b2d3.tar.gz
rust-ab3a2a024fb58d5ad3e893f1d5694468b187b2d3.zip
Unify copying data from enclave to userspace
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/sgx/abi/usercalls/alloc.rs10
1 files changed, 3 insertions, 7 deletions
diff --git a/library/std/src/sys/sgx/abi/usercalls/alloc.rs b/library/std/src/sys/sgx/abi/usercalls/alloc.rs
index 3792a3820a5..9a64b7e4b15 100644
--- a/library/std/src/sys/sgx/abi/usercalls/alloc.rs
+++ b/library/std/src/sys/sgx/abi/usercalls/alloc.rs
@@ -225,13 +225,9 @@ where
     /// 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
         }
     }