summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSebastian Holmin <sebastain@holmin@mullvad.com>2025-07-07 15:52:15 +0200
committerSebastian Holmin <sebastian.holmin@mullvad.net>2025-07-09 16:28:05 +0200
commita761a974cbfbfb2e2203faff227f43567112e7c4 (patch)
tree7b5c0f975d840b951fdde450ec6e34f32bacd3ed
parent8d96b12c8442d180669993d425dbe9a56500bf1f (diff)
downloadmullvadvpn-a761a974cbfbfb2e2203faff227f43567112e7c4.tar.xz
mullvadvpn-a761a974cbfbfb2e2203faff227f43567112e7c4.zip
Add unsafe block in unsafe fn
Also make extern blocks unsafe
-rw-r--r--mullvad-ios/src/api_client/access_method_settings.rs4
-rw-r--r--mullvad-ios/src/api_client/account.rs9
-rw-r--r--mullvad-ios/src/api_client/address_cache_provider.rs2
-rw-r--r--mullvad-ios/src/api_client/api.rs9
-rw-r--r--mullvad-ios/src/api_client/device.rs31
-rw-r--r--mullvad-ios/src/api_client/helpers.rs30
-rw-r--r--mullvad-ios/src/api_client/mod.rs4
-rw-r--r--mullvad-ios/src/api_client/problem_report.rs11
-rw-r--r--mullvad-ios/src/api_client/response.rs24
-rw-r--r--mullvad-ios/src/api_client/retry_strategy.rs2
-rw-r--r--mullvad-ios/src/api_client/shadowsocks_loader.rs2
-rw-r--r--mullvad-ios/src/api_client/storekit.rs15
-rw-r--r--mullvad-ios/src/ephemeral_peer_proxy/mod.rs2
-rw-r--r--mullvad-ios/src/shadowsocks_proxy/ffi.rs15
-rw-r--r--mullvad-ios/src/tunnel_obfuscator_proxy/ffi.rs31
15 files changed, 101 insertions, 90 deletions
diff --git a/mullvad-ios/src/api_client/access_method_settings.rs b/mullvad-ios/src/api_client/access_method_settings.rs
index 2870047e24..40f0acd714 100644
--- a/mullvad-ios/src/api_client/access_method_settings.rs
+++ b/mullvad-ios/src/api_client/access_method_settings.rs
@@ -143,7 +143,7 @@ pub unsafe extern "C" fn init_access_method_settings_wrapper(
)
};
- let custom = access_methods_from_raw_array(custom_methods_raw, custom_method_count);
+ let custom = unsafe { access_methods_from_raw_array(custom_methods_raw, custom_method_count) };
let settings = Settings::new(direct, mullvad_bridges, encrypted_dns_proxy, custom);
let context = SwiftAccessMethodSettingsContext { settings };
SwiftAccessMethodSettingsWrapper::new(context)
@@ -177,7 +177,7 @@ impl SwiftAccessMethodSettingsWrapper {
}
pub unsafe fn into_rust_context(self) -> Box<SwiftAccessMethodSettingsContext> {
- Box::from_raw(self.0)
+ unsafe { Box::from_raw(self.0) }
}
}
diff --git a/mullvad-ios/src/api_client/account.rs b/mullvad-ios/src/api_client/account.rs
index dde75332ac..eb755f3191 100644
--- a/mullvad-ios/src/api_client/account.rs
+++ b/mullvad-ios/src/api_client/account.rs
@@ -37,7 +37,8 @@ pub unsafe extern "C" fn mullvad_ios_get_account(
retry_strategy: SwiftRetryStrategy,
account_number: *const c_char,
) -> SwiftCancelHandle {
- let completion_handler = SwiftCompletionHandler::new(CompletionCookie::new(completion_cookie));
+ let completion_handler =
+ SwiftCompletionHandler::new(unsafe { CompletionCookie::new(completion_cookie) });
let Ok(tokio_handle) = crate::mullvad_ios_runtime() else {
completion_handler.finish(SwiftMullvadApiResponse::no_tokio_runtime());
@@ -92,7 +93,8 @@ pub unsafe extern "C" fn mullvad_ios_create_account(
completion_cookie: *mut libc::c_void,
retry_strategy: SwiftRetryStrategy,
) -> SwiftCancelHandle {
- let completion_handler = SwiftCompletionHandler::new(CompletionCookie::new(completion_cookie));
+ let completion_handler =
+ SwiftCompletionHandler::new(unsafe { CompletionCookie::new(completion_cookie) });
let Ok(tokio_handle) = crate::mullvad_ios_runtime() else {
completion_handler.finish(SwiftMullvadApiResponse::no_tokio_runtime());
@@ -139,7 +141,8 @@ pub unsafe extern "C" fn mullvad_ios_delete_account(
retry_strategy: SwiftRetryStrategy,
account_number: *const c_char,
) -> SwiftCancelHandle {
- let completion_handler = SwiftCompletionHandler::new(CompletionCookie::new(completion_cookie));
+ let completion_handler =
+ SwiftCompletionHandler::new(unsafe { CompletionCookie::new(completion_cookie) });
let Ok(tokio_handle) = crate::mullvad_ios_runtime() else {
completion_handler.finish(SwiftMullvadApiResponse::no_tokio_runtime());
diff --git a/mullvad-ios/src/api_client/address_cache_provider.rs b/mullvad-ios/src/api_client/address_cache_provider.rs
index 9d5f656c62..0458ae2fe3 100644
--- a/mullvad-ios/src/api_client/address_cache_provider.rs
+++ b/mullvad-ios/src/api_client/address_cache_provider.rs
@@ -3,7 +3,7 @@ use std::{ffi::c_void, net::SocketAddr};
use super::get_string;
-extern "C" {
+unsafe extern "C" {
/// Return the latest available endpoint, or a default one if none are cached
///
/// # SAFETY
diff --git a/mullvad-ios/src/api_client/api.rs b/mullvad-ios/src/api_client/api.rs
index bc2fdd324f..20fe2ba248 100644
--- a/mullvad-ios/src/api_client/api.rs
+++ b/mullvad-ios/src/api_client/api.rs
@@ -36,7 +36,8 @@ pub unsafe extern "C" fn mullvad_ios_get_addresses(
completion_cookie: *mut libc::c_void,
retry_strategy: SwiftRetryStrategy,
) -> SwiftCancelHandle {
- let completion_handler = SwiftCompletionHandler::new(CompletionCookie::new(completion_cookie));
+ let completion_handler =
+ SwiftCompletionHandler::new(unsafe { CompletionCookie::new(completion_cookie) });
let Ok(tokio_handle) = crate::mullvad_ios_runtime() else {
completion_handler.finish(SwiftMullvadApiResponse::no_tokio_runtime());
@@ -81,7 +82,8 @@ pub unsafe extern "C" fn mullvad_ios_api_addrs_available(
retry_strategy: SwiftRetryStrategy,
access_method_setting: *const c_void,
) -> SwiftCancelHandle {
- let completion_handler = SwiftCompletionHandler::new(CompletionCookie::new(completion_cookie));
+ let completion_handler =
+ SwiftCompletionHandler::new(unsafe { CompletionCookie::new(completion_cookie) });
let Ok(tokio_handle) = crate::mullvad_ios_runtime() else {
completion_handler.finish(SwiftMullvadApiResponse::no_tokio_runtime());
@@ -155,7 +157,8 @@ pub unsafe extern "C" fn mullvad_ios_get_relays(
retry_strategy: SwiftRetryStrategy,
etag: *const c_char,
) -> SwiftCancelHandle {
- let completion_handler = SwiftCompletionHandler::new(CompletionCookie::new(completion_cookie));
+ let completion_handler =
+ SwiftCompletionHandler::new(unsafe { CompletionCookie::new(completion_cookie) });
let Ok(tokio_handle) = crate::mullvad_ios_runtime() else {
completion_handler.finish(SwiftMullvadApiResponse::no_tokio_runtime());
diff --git a/mullvad-ios/src/api_client/device.rs b/mullvad-ios/src/api_client/device.rs
index 6a6ee1b07e..e0eb44fa9f 100644
--- a/mullvad-ios/src/api_client/device.rs
+++ b/mullvad-ios/src/api_client/device.rs
@@ -42,7 +42,8 @@ pub unsafe extern "C" fn mullvad_ios_get_device(
account_number: *const c_char,
identifier: *const c_char,
) -> SwiftCancelHandle {
- let completion_handler = SwiftCompletionHandler::new(CompletionCookie::new(completion_cookie));
+ let completion_handler =
+ SwiftCompletionHandler::new(unsafe { CompletionCookie::new(completion_cookie) });
let Ok(tokio_handle) = crate::mullvad_ios_runtime() else {
completion_handler.finish(SwiftMullvadApiResponse::no_tokio_runtime());
@@ -52,8 +53,8 @@ pub unsafe extern "C" fn mullvad_ios_get_device(
let api_context = api_context.rust_context();
// Safety: The caller must guarantee that `retry_strategy` is not null and has not been freed
let retry_strategy = unsafe { retry_strategy.into_rust() };
- let account_number = get_string(account_number);
- let identifier = get_string(identifier);
+ let account_number = unsafe { get_string(account_number) };
+ let identifier = unsafe { get_string(identifier) };
let completion = completion_handler.clone();
let task = tokio_handle.spawn(async move {
@@ -100,7 +101,8 @@ pub unsafe extern "C" fn mullvad_ios_get_devices(
retry_strategy: SwiftRetryStrategy,
account_number: *const c_char,
) -> SwiftCancelHandle {
- let completion_handler = SwiftCompletionHandler::new(CompletionCookie::new(completion_cookie));
+ let completion_handler =
+ SwiftCompletionHandler::new(unsafe { CompletionCookie::new(completion_cookie) });
let Ok(tokio_handle) = crate::mullvad_ios_runtime() else {
completion_handler.finish(SwiftMullvadApiResponse::no_tokio_runtime());
@@ -110,7 +112,7 @@ pub unsafe extern "C" fn mullvad_ios_get_devices(
let api_context = api_context.rust_context();
// Safety: The caller must guarantee that `retry_strategy` is not null and has not been freed
let retry_strategy = unsafe { retry_strategy.into_rust() };
- let account_number = get_string(account_number);
+ let account_number = unsafe { get_string(account_number) };
let completion = completion_handler.clone();
let task = tokio_handle.spawn(async move {
@@ -158,7 +160,8 @@ pub unsafe extern "C" fn mullvad_ios_create_device(
account_number: *const c_char,
public_key: *const u8,
) -> SwiftCancelHandle {
- let completion_handler = SwiftCompletionHandler::new(CompletionCookie::new(completion_cookie));
+ let completion_handler =
+ SwiftCompletionHandler::new(unsafe { CompletionCookie::new(completion_cookie) });
let Ok(tokio_handle) = crate::mullvad_ios_runtime() else {
completion_handler.finish(SwiftMullvadApiResponse::no_tokio_runtime());
@@ -168,7 +171,7 @@ pub unsafe extern "C" fn mullvad_ios_create_device(
let api_context = api_context.rust_context();
// Safety: The caller must guarantee that `retry_strategy` is not null and has not been freed
let retry_strategy = unsafe { retry_strategy.into_rust() };
- let account_number = get_string(account_number);
+ let account_number = unsafe { get_string(account_number) };
// Safety: `public_key` pointer must be a valid pointer to 32 unsigned bytes.
let pub_key: [u8; 32] = unsafe { ptr::read(public_key as *const [u8; 32]) };
@@ -218,7 +221,8 @@ pub unsafe extern "C" fn mullvad_ios_delete_device(
account_number: *const c_char,
identifier: *const c_char,
) -> SwiftCancelHandle {
- let completion_handler = SwiftCompletionHandler::new(CompletionCookie::new(completion_cookie));
+ let completion_handler =
+ SwiftCompletionHandler::new(unsafe { CompletionCookie::new(completion_cookie) });
let Ok(tokio_handle) = crate::mullvad_ios_runtime() else {
completion_handler.finish(SwiftMullvadApiResponse::no_tokio_runtime());
@@ -228,8 +232,8 @@ pub unsafe extern "C" fn mullvad_ios_delete_device(
let api_context = api_context.rust_context();
// Safety: The caller must guarantee that `retry_strategy` is not null and has not been freed
let retry_strategy = unsafe { retry_strategy.into_rust() };
- let account_number = get_string(account_number);
- let identifier = get_string(identifier);
+ let account_number = unsafe { get_string(account_number) };
+ let identifier = unsafe { get_string(identifier) };
let completion = completion_handler.clone();
let task = tokio_handle.spawn(async move {
@@ -279,7 +283,8 @@ pub unsafe extern "C" fn mullvad_ios_rotate_device_key(
identifier: *const c_char,
public_key: *const u8,
) -> SwiftCancelHandle {
- let completion_handler = SwiftCompletionHandler::new(CompletionCookie::new(completion_cookie));
+ let completion_handler =
+ SwiftCompletionHandler::new(unsafe { CompletionCookie::new(completion_cookie) });
let Ok(tokio_handle) = crate::mullvad_ios_runtime() else {
completion_handler.finish(SwiftMullvadApiResponse::no_tokio_runtime());
@@ -289,8 +294,8 @@ pub unsafe extern "C" fn mullvad_ios_rotate_device_key(
let api_context = api_context.rust_context();
// Safety: The caller must guarantee that `retry_strategy` is not null and has not been freed
let retry_strategy = unsafe { retry_strategy.into_rust() };
- let account_number = get_string(account_number);
- let identifier = get_string(identifier);
+ let account_number = unsafe { get_string(account_number) };
+ let identifier = unsafe { get_string(identifier) };
// Safety: `public_key` pointer must be a valid pointer to 32 unsigned bytes.
let pub_key: [u8; 32] = unsafe { ptr::read(public_key as *const [u8; 32]) };
diff --git a/mullvad-ios/src/api_client/helpers.rs b/mullvad-ios/src/api_client/helpers.rs
index 556b679d71..e363c5862c 100644
--- a/mullvad-ios/src/api_client/helpers.rs
+++ b/mullvad-ios/src/api_client/helpers.rs
@@ -46,14 +46,15 @@ pub unsafe extern "C" fn new_shadowsocks_access_method_setting(
c_password: *const c_char,
c_cipher: *const c_char,
) -> *const c_void {
- let endpoint: SocketAddr = if let Some(ip_address) = parse_ip_addr(address, address_len) {
- SocketAddr::new(ip_address, port)
- } else {
- return std::ptr::null();
- };
+ let endpoint: SocketAddr =
+ if let Some(ip_address) = unsafe { parse_ip_addr(address, address_len) } {
+ SocketAddr::new(ip_address, port)
+ } else {
+ return std::ptr::null();
+ };
- let password = get_string(c_password);
- let cipher = get_string(c_cipher);
+ let password = unsafe { get_string(c_password) };
+ let cipher = unsafe { get_string(c_cipher) };
let shadowsocks_configuration = Shadowsocks {
endpoint,
@@ -79,18 +80,19 @@ pub unsafe extern "C" fn new_socks5_access_method_setting(
c_username: *const c_char,
c_password: *const c_char,
) -> *const c_void {
- let endpoint: SocketAddr = if let Some(ip_address) = parse_ip_addr(address, address_len) {
- SocketAddr::new(ip_address, port)
- } else {
- return std::ptr::null();
- };
+ let endpoint: SocketAddr =
+ if let Some(ip_address) = unsafe { parse_ip_addr(address, address_len) } {
+ SocketAddr::new(ip_address, port)
+ } else {
+ return std::ptr::null();
+ };
let auth = {
if c_username.is_null() || c_password.is_null() {
None
} else {
- let username = get_string(c_username);
- let password = get_string(c_password);
+ let username = unsafe { get_string(c_username) };
+ let password = unsafe { get_string(c_password) };
SocksAuth::new(username, password).ok()
}
};
diff --git a/mullvad-ios/src/api_client/mod.rs b/mullvad-ios/src/api_client/mod.rs
index 7095d46b35..82535d0e40 100644
--- a/mullvad-ios/src/api_client/mod.rs
+++ b/mullvad-ios/src/api_client/mod.rs
@@ -91,7 +91,7 @@ pub unsafe extern "C" fn mullvad_api_update_access_methods(
api_context: SwiftApiContext,
settings_wrapper: SwiftAccessMethodSettingsWrapper,
) {
- let access_methods = settings_wrapper.into_rust_context().settings;
+ let access_methods = unsafe { settings_wrapper.into_rust_context().settings };
api_context
.rust_context()
.update_access_methods(access_methods);
@@ -109,7 +109,7 @@ pub unsafe extern "C" fn mullvad_api_use_access_method(
) {
let api_context = api_context.rust_context();
// SAFETY: See Safety notes for `get_string`
- let id = get_string(access_method_id);
+ let id = unsafe { get_string(access_method_id) };
let Some(id) = Id::from_string(id) else {
return;
diff --git a/mullvad-ios/src/api_client/problem_report.rs b/mullvad-ios/src/api_client/problem_report.rs
index ce1bb15f1d..06101b86f7 100644
--- a/mullvad-ios/src/api_client/problem_report.rs
+++ b/mullvad-ios/src/api_client/problem_report.rs
@@ -42,7 +42,8 @@ pub unsafe extern "C" fn mullvad_ios_send_problem_report(
retry_strategy: SwiftRetryStrategy,
request: SwiftProblemReportRequest,
) -> SwiftCancelHandle {
- let completion_handler = SwiftCompletionHandler::new(CompletionCookie::new(completion_cookie));
+ let completion_handler =
+ SwiftCompletionHandler::new(unsafe { CompletionCookie::new(completion_cookie) });
let completion = completion_handler.clone();
let Ok(tokio_handle) = crate::mullvad_ios_runtime() else {
@@ -122,9 +123,9 @@ struct ProblemReportRequest {
impl ProblemReportRequest {
// SAFETY: the members of `SwiftProblemReportRequest` must point to null-terminated strings
unsafe fn from_swift_parameters(request: SwiftProblemReportRequest) -> Option<Self> {
- let address = get_string(request.address);
- let message = get_string(request.message);
- let log = get_string(request.log).into();
+ let address = unsafe { get_string(request.address) };
+ let message = unsafe { get_string(request.message) };
+ let log = unsafe { get_string(request.log) }.into();
let metadata = if request.metadata.inner.is_null() {
BTreeMap::new()
@@ -132,7 +133,7 @@ impl ProblemReportRequest {
let swift_map = &request.metadata;
let mut converted_map = BTreeMap::new();
- if let Some(inner) = swift_map.inner.as_ref() {
+ if let Some(inner) = unsafe { swift_map.inner.as_ref() } {
for (key, value) in &inner.0 {
converted_map.insert(key.clone(), value.clone());
}
diff --git a/mullvad-ios/src/api_client/response.rs b/mullvad-ios/src/api_client/response.rs
index 86c6c57c45..df7795b0c2 100644
--- a/mullvad-ios/src/api_client/response.rs
+++ b/mullvad-ios/src/api_client/response.rs
@@ -144,19 +144,21 @@ impl SwiftMullvadApiResponse {
/// is not safe to call multiple times with the same `SwiftMullvadApiResponse`.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn mullvad_response_drop(response: SwiftMullvadApiResponse) {
- if !response.body.is_null() {
- let _ = Vec::from_raw_parts(response.body, response.body_size, response.body_size);
- }
+ unsafe {
+ if !response.body.is_null() {
+ let _ = Vec::from_raw_parts(response.body, response.body_size, response.body_size);
+ }
- if !response.etag.is_null() {
- let _ = CString::from_raw(response.etag);
- }
+ if !response.etag.is_null() {
+ let _ = CString::from_raw(response.etag);
+ }
- if !response.error_description.is_null() {
- let _ = CString::from_raw(response.error_description);
- }
+ if !response.error_description.is_null() {
+ let _ = CString::from_raw(response.error_description);
+ }
- if !response.server_response_code.is_null() {
- let _ = CString::from_raw(response.server_response_code);
+ if !response.server_response_code.is_null() {
+ let _ = CString::from_raw(response.server_response_code);
+ }
}
}
diff --git a/mullvad-ios/src/api_client/retry_strategy.rs b/mullvad-ios/src/api_client/retry_strategy.rs
index 9cb407349a..06b9aa94db 100644
--- a/mullvad-ios/src/api_client/retry_strategy.rs
+++ b/mullvad-ios/src/api_client/retry_strategy.rs
@@ -9,7 +9,7 @@ impl SwiftRetryStrategy {
/// # Safety
/// The pointer must be a pointing to a valid instance of a `Box<RetryStrategy>`.
pub unsafe fn into_rust(self) -> RetryStrategy {
- *Box::from_raw(self.0)
+ unsafe { *Box::from_raw(self.0) }
}
}
diff --git a/mullvad-ios/src/api_client/shadowsocks_loader.rs b/mullvad-ios/src/api_client/shadowsocks_loader.rs
index 161ee8a30a..2d63b179d3 100644
--- a/mullvad-ios/src/api_client/shadowsocks_loader.rs
+++ b/mullvad-ios/src/api_client/shadowsocks_loader.rs
@@ -1,7 +1,7 @@
use std::ffi::c_void;
use talpid_types::net::proxy::Shadowsocks;
-extern "C" {
+unsafe extern "C" {
/// Creates a `Shadowsocks` configuration.
///
/// # SAFETY
diff --git a/mullvad-ios/src/api_client/storekit.rs b/mullvad-ios/src/api_client/storekit.rs
index 7d8d76545b..f5e149b7a4 100644
--- a/mullvad-ios/src/api_client/storekit.rs
+++ b/mullvad-ios/src/api_client/storekit.rs
@@ -43,7 +43,8 @@ pub unsafe extern "C" fn mullvad_ios_legacy_storekit_payment(
body: *const u8,
body_size: usize,
) -> SwiftCancelHandle {
- let completion_handler = SwiftCompletionHandler::new(CompletionCookie::new(completion_cookie));
+ let completion_handler =
+ SwiftCompletionHandler::new(unsafe { CompletionCookie::new(completion_cookie) });
let Ok(tokio_handle) = crate::mullvad_ios_runtime() else {
completion_handler.finish(SwiftMullvadApiResponse::no_tokio_runtime());
@@ -57,7 +58,7 @@ pub unsafe extern "C" fn mullvad_ios_legacy_storekit_payment(
let completion = completion_handler.clone();
// SAFETY: See param documentation for `account_number`.
- let account_number = AccountNumber::from(get_string(account_number));
+ let account_number = AccountNumber::from(unsafe { get_string(account_number) });
// SAFETY: See param documentation for `body`.
let body = unsafe { std::slice::from_raw_parts(body, body_size) }.to_vec();
@@ -117,7 +118,8 @@ pub unsafe extern "C" fn mullvad_ios_init_storekit_payment(
retry_strategy: SwiftRetryStrategy,
account_number: *const c_char,
) -> SwiftCancelHandle {
- let completion_handler = SwiftCompletionHandler::new(CompletionCookie::new(completion_cookie));
+ let completion_handler =
+ SwiftCompletionHandler::new(unsafe { CompletionCookie::new(completion_cookie) });
let Ok(tokio_handle) = crate::mullvad_ios_runtime() else {
completion_handler.finish(SwiftMullvadApiResponse::no_tokio_runtime());
@@ -132,7 +134,7 @@ pub unsafe extern "C" fn mullvad_ios_init_storekit_payment(
let completion = completion_handler.clone();
// SAFETY: See param documentation for `account_number`.
- let account_number = AccountNumber::from(get_string(account_number));
+ let account_number = AccountNumber::from(unsafe { get_string(account_number) });
let task = tokio_handle.spawn(async move {
match mullvad_ios_init_storekit_payment_inner(
@@ -193,7 +195,8 @@ pub unsafe extern "C" fn mullvad_ios_check_storekit_payment(
body: *const u8,
body_size: usize,
) -> SwiftCancelHandle {
- let completion_handler = SwiftCompletionHandler::new(CompletionCookie::new(completion_cookie));
+ let completion_handler =
+ SwiftCompletionHandler::new(unsafe { CompletionCookie::new(completion_cookie) });
let Ok(tokio_handle) = crate::mullvad_ios_runtime() else {
completion_handler.finish(SwiftMullvadApiResponse::no_tokio_runtime());
@@ -207,7 +210,7 @@ pub unsafe extern "C" fn mullvad_ios_check_storekit_payment(
let completion = completion_handler.clone();
// SAFETY: See param documentation for `account_number`.
- let account_number = AccountNumber::from(get_string(account_number));
+ let account_number = AccountNumber::from(unsafe { get_string(account_number) });
// SAFETY: See param documentation for `body`.
let body = unsafe { std::slice::from_raw_parts(body, body_size) }.to_vec();
diff --git a/mullvad-ios/src/ephemeral_peer_proxy/mod.rs b/mullvad-ios/src/ephemeral_peer_proxy/mod.rs
index 9942c78f62..e0fc9420aa 100644
--- a/mullvad-ios/src/ephemeral_peer_proxy/mod.rs
+++ b/mullvad-ios/src/ephemeral_peer_proxy/mod.rs
@@ -94,7 +94,7 @@ impl Drop for DaitaParameters {
}
}
-extern "C" {
+unsafe extern "C" {
/// To be called when ephemeral peer exchange has finished. All parameters except
/// `raw_packet_tunnel` are optional.
///
diff --git a/mullvad-ios/src/shadowsocks_proxy/ffi.rs b/mullvad-ios/src/shadowsocks_proxy/ffi.rs
index 815862fb52..cf038d6933 100644
--- a/mullvad-ios/src/shadowsocks_proxy/ffi.rs
+++ b/mullvad-ios/src/shadowsocks_proxy/ffi.rs
@@ -35,16 +35,17 @@ pub unsafe extern "C" fn start_shadowsocks_proxy(
.init();
});
- let forward_ip =
- if let Some(forward_address) = { parse_ip_addr(forward_address, forward_address_len) } {
- forward_address
- } else {
- return -1;
- };
+ let forward_ip = if let Some(forward_address) =
+ { unsafe { parse_ip_addr(forward_address, forward_address_len) } }
+ {
+ forward_address
+ } else {
+ return -1;
+ };
let forward_socket_addr = SocketAddr::new(forward_ip, forward_port);
- let bridge_ip = if let Some(addr) = { parse_ip_addr(addr, addr_len) } {
+ let bridge_ip = if let Some(addr) = { unsafe { parse_ip_addr(addr, addr_len) } } {
addr
} else {
return -1;
diff --git a/mullvad-ios/src/tunnel_obfuscator_proxy/ffi.rs b/mullvad-ios/src/tunnel_obfuscator_proxy/ffi.rs
index 849d4336cc..50ac53d3be 100644
--- a/mullvad-ios/src/tunnel_obfuscator_proxy/ffi.rs
+++ b/mullvad-ios/src/tunnel_obfuscator_proxy/ffi.rs
@@ -26,14 +26,11 @@ pub unsafe extern "C" fn start_udp2tcp_obfuscator_proxy(
) -> i32 {
init_logging();
- let peer_sock_addr = throw_int_error!(get_socket_address(
- peer_address,
- peer_address_len,
- peer_port
- ));
+ let peer_sock_addr =
+ throw_int_error!(unsafe { get_socket_address(peer_address, peer_address_len, peer_port) });
let result = TunnelObfuscatorRuntime::new_udp2tcp(peer_sock_addr).run();
- start(proxy_handle, result)
+ unsafe { start(proxy_handle, result) }
}
#[unsafe(no_mangle)]
@@ -45,14 +42,11 @@ pub unsafe extern "C" fn start_shadowsocks_obfuscator_proxy(
) -> i32 {
init_logging();
- let peer_sock_addr = throw_int_error!(get_socket_address(
- peer_address,
- peer_address_len,
- peer_port
- ));
+ let peer_sock_addr =
+ throw_int_error!(unsafe { get_socket_address(peer_address, peer_address_len, peer_port) });
let result = TunnelObfuscatorRuntime::new_shadowsocks(peer_sock_addr).run();
- start(proxy_handle, result)
+ unsafe { start(proxy_handle, result) }
}
#[unsafe(no_mangle)]
@@ -66,16 +60,13 @@ pub unsafe extern "C" fn start_quic_obfuscator_proxy(
) -> i32 {
init_logging();
- let peer_sock_addr = throw_int_error!(get_socket_address(
- peer_address,
- peer_address_len,
- peer_port
- ));
- let hostname = get_string(hostname);
- let token = get_string(token);
+ let peer_sock_addr =
+ throw_int_error!(unsafe { get_socket_address(peer_address, peer_address_len, peer_port) });
+ let hostname = unsafe { get_string(hostname) };
+ let token = unsafe { get_string(token) };
let result = TunnelObfuscatorRuntime::new_quic(peer_sock_addr, hostname, token).run();
- start(proxy_handle, result)
+ unsafe { start(proxy_handle, result) }
}
fn init_logging() {