Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Jul 24, 2024
1 parent c336c51 commit fe38bd8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 2 additions & 10 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Expand Down

0 comments on commit fe38bd8

Please sign in to comment.