summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJoakim Hulthe <joakim.hulthe@mullvad.net>2025-02-13 13:03:29 +0100
committerJoakim Hulthe <joakim.hulthe@mullvad.net>2025-02-25 13:37:39 +0100
commit7268ceb562ad750b117f9724d696dbdcee6fd26b (patch)
tree0bfb9e1717cc575928a0f34fcbd246899ac1d738
parentf972cb95fbb143bfbb7334d1762b48591bede591 (diff)
downloadmullvadvpn-7268ceb562ad750b117f9724d696dbdcee6fd26b.tar.xz
mullvadvpn-7268ceb562ad750b117f9724d696dbdcee6fd26b.zip
Add safety comment to talpid_wireguard::wireguard_go
-rw-r--r--talpid-wireguard/src/wireguard_go/mod.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/talpid-wireguard/src/wireguard_go/mod.rs b/talpid-wireguard/src/wireguard_go/mod.rs
index 73b22a452f..6e082870f4 100644
--- a/talpid-wireguard/src/wireguard_go/mod.rs
+++ b/talpid-wireguard/src/wireguard_go/mod.rs
@@ -761,12 +761,16 @@ mod logging {
use std::ffi::c_char;
// Callback that receives messages from WireGuard
+ //
+ // # Safety
+ // - `msg` must be a valid pointer to a null-terminated UTF-8 string.
pub unsafe extern "system" fn wg_go_logging_callback(
level: WgLogLevel,
msg: *const c_char,
context: u64,
) {
let managed_msg = if !msg.is_null() {
+ // SAFETY: caller promises that the pointer is valid.
unsafe { std::ffi::CStr::from_ptr(msg).to_string_lossy().to_string() }
} else {
"Logging message from WireGuard is NULL".to_string()