std: check if TCS is a null pointer

This commit is contained in:
joboet 2022-09-05 11:42:46 +02:00
parent 9358d09a55
commit 2fa58080cb
No known key found for this signature in database
GPG key ID: 704E0149B0194B3C

View file

@ -7,7 +7,11 @@ use fortanix_sgx_abi::Tcs;
#[unstable(feature = "sgx_platform", issue = "56975")] #[unstable(feature = "sgx_platform", issue = "56975")]
pub fn current() -> Tcs { pub fn current() -> Tcs {
extern "C" { extern "C" {
fn get_tcs_addr() -> Tcs; fn get_tcs_addr() -> *mut u8;
}
let addr = unsafe { get_tcs_addr() };
match Tcs::new(addr) {
Some(tcs) => tcs,
None => rtabort!("TCS must not be placed at address zero (this is a linker error)"),
} }
unsafe { get_tcs_addr() }
} }