diff --git a/crates/fs-mistrust/src/imp.rs b/crates/fs-mistrust/src/imp.rs index fb89b3903..3e0c5119c 100644 --- a/crates/fs-mistrust/src/imp.rs +++ b/crates/fs-mistrust/src/imp.rs @@ -196,8 +196,6 @@ impl<'a> super::Verifier<'a> { return; } - // mut not used when compiling or iOS - #[allow(unused_mut)] let mut forbidden_bits = if !self.readable_okay && path_type == PathType::Final { // If this is the target object, and it must not be readable, then // we forbid it to be group-rwx and all-rwx. @@ -232,6 +230,13 @@ impl<'a> super::Verifier<'a> { forbidden_bits &= !0o070; } + // rational: on iOS the platform already protect user data, and not setting this poses + // issue with the default application data folder. + #[cfg(target_os = "ios")] + { + forbidden_bits &= !0o070; + } + let bad_bits = meta.mode() & forbidden_bits; if bad_bits != 0 { errors.push(Error::BadPermission( diff --git a/crates/tor-circmgr/src/mgr.rs b/crates/tor-circmgr/src/mgr.rs index e9306800d..2033c9013 100644 --- a/crates/tor-circmgr/src/mgr.rs +++ b/crates/tor-circmgr/src/mgr.rs @@ -1325,16 +1325,18 @@ impl AbstractCircMgr { /// no longer be given out for new circuits. pub(crate) fn expire_circs(&self, now: Instant) { let mut list = self.circs.lock().expect("poisoned lock"); - let dirty_cutoff = now - self.circuit_timing().max_dirtiness; - list.expire_circs(now, dirty_cutoff); + if let Some(dirty_cutoff) = now.checked_sub(self.circuit_timing().max_dirtiness) { + list.expire_circs(now, dirty_cutoff); + } } /// Consider expiring the circuit with given circuit `id`, /// according to the rules in `config` and the current time `now`. pub(crate) fn expire_circ(&self, circ_id: &::Id, now: Instant) { let mut list = self.circs.lock().expect("poisoned lock"); - let dirty_cutoff = now - self.circuit_timing().max_dirtiness; - list.expire_circ(circ_id, now, dirty_cutoff); + if let Some(dirty_cutoff) = now.checked_sub(self.circuit_timing().max_dirtiness) { + list.expire_circ(circ_id, now, dirty_cutoff); + } } /// Return the number of open circuits held by this circuit manager. diff --git a/crates/tor-guardmgr/src/skew.rs b/crates/tor-guardmgr/src/skew.rs index d81c6b08f..2d4bb32a2 100644 --- a/crates/tor-guardmgr/src/skew.rs +++ b/crates/tor-guardmgr/src/skew.rs @@ -22,9 +22,9 @@ pub(crate) struct SkewObservation { impl SkewObservation { /// Return true if this observation has been made more recently than - /// `cutoff`. - pub(crate) fn more_recent_than(&self, cutoff: Instant) -> bool { - self.when > cutoff + /// `cutoff`. If cutoff is None, consider it's very far in the past. + pub(crate) fn more_recent_than(&self, cutoff: Option) -> bool { + cutoff.map_or(true, |cutoff| self.when > cutoff) } } @@ -108,7 +108,7 @@ impl SkewEstimate { now: Instant, ) -> Option { // Only consider skew observations reported at least this recently. - let cutoff = now - Duration::from_secs(3600); + let cutoff = now.checked_sub(Duration::from_secs(3600)); // Don't even look at our observations unless we have at least this // many. (This value is chosen somewhat arbitrarily.)