From fe38bd87c50e6188658e50849fa01a94c51045e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B6nnhager?= Date: Wed, 24 Jul 2024 14:55:41 +0200 Subject: [PATCH] fixup --- src/lib.rs | 4 +--- src/state.rs | 12 ++---------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index de73a92..b715c46 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -439,9 +439,7 @@ impl PfCtl { .get_states_inner()? .into_iter() .map(|state| { - // SAFETY: `DIOCGETSTATE` calls `pf_state_export`, where `pfsync_state` is zero-initialized. - // https://github.com/apple-oss-distributions/xnu/blob/main/bsd/net/pf_ioctl.c#L1247 - // https://github.com/apple-oss-distributions/xnu/blob/main/bsd/net/pf_ioctl.c#L3583 + // SAFETY: `setup_pfioc_states` zero-initializes each `pfsync_state`. unsafe { State::new(state) } }) .collect(); diff --git a/src/state.rs b/src/state.rs index 760d33a..b676058 100644 --- a/src/state.rs +++ b/src/state.rs @@ -24,19 +24,11 @@ impl fmt::Debug for State { } impl State { - /// Wrap `pfsync_state` so that it can be accessed safely. + /// Wrap a `pfsync_state` so that it can be accessed safely. /// /// # Safety /// - /// `sync_state.lan` and `sync_state.ext_lan` must set an address and port: - /// * If `sync_state.af_lan == PF_INET`, then these fields must be initialized: - /// * `sync_state.lan.addr.pfa._v4addr` - /// * `sync_state.ext_lan.addr.pfa._v4addr` - /// * If `sync_state.af_lan == PF_INET6`, then these fields must be initialized: - /// * `sync_state.lan.addr.pfa._v6addr` - /// * `sync_state.ext_lan.addr.pfa._v6addr` - /// * `sync_state.lan.xport.port` must be initialized. - /// * `sync_state.ext_lan.xport.port` must be initialized. + /// All memory in `sync_state` must be initialized. pub(crate) unsafe fn new(sync_state: pfsync_state) -> State { State { sync_state } }