Skip to content
Myr

Merge pull request #2082 from nikolauspschuetz/fix-changed-time-overflow-panic

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fix panic on out-of-range '@' Unix timestamp in time filters

authored by Thayne McCombs · committed by GitHub · parents 0f1f967, 5becb9d · Browse files · 2 files+10 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−1 removed

  • other:+10 added−1 removed

2 files+10 added−1 removed

modified:src/filter/time.rs+9 added-1 removed
40 unmodified lines
41 .into(),42 )43 } else {44 let timestamp_secs: u64 = s.strip_prefix('@')?.parse().ok()?;45 Some(UNIX_EPOCH + Duration::from_secs(timestamp_secs))45 UNIX_EPOCH.checked_add(Duration::from_secs(timestamp_secs))46 }47 }4849 pub fn before(s: &str) -> Option<TimeFilter> {
148 unmodified lines
198 .unwrap()199 .applies_to(&t1s_later)200 );201 }202203 #[test]204 fn out_of_range_unix_timestamp_is_rejected() {205 // A '@' timestamp large enough to overflow SystemTime must return206 // None rather than panicking.207 assert!(TimeFilter::before(&format!("@{}", u64::MAX)).is_none());208 assert!(TimeFilter::after(&format!("@{}", u64::MAX)).is_none());209 }210}
modified:CHANGELOG.md+1 added
11 unmodified lines
12- Handle invalid working directories gracefully when using `--full-path`, see #1900 (@Xavrir).13- Fire the "search pattern contains a path separator" diagnostic for any pattern containing `/`, not just patterns that happen to name an existing directory. Preserves the legacy Windows behaviour that also flags native `\` separators when the pattern resolves to a real directory. See #1873.14- Also fire the "search pattern contains a path separator" diagnostic for `--and` patterns, not only the primary positional pattern. `--and` patterns are matched against the file name just like the primary pattern, so a path separator in them silently returned zero results. See #1873.15- Fix bug where passing "-" as a directory argument didn't actually search that directory, see #849 (@Sean-Kenneth-Doherty).16- Fix panic when `--changed-before`/`--changed-within` is given an out-of-range `@` Unix timestamp; the value is now rejected gracefully, see #2081 (@nikolauspschuetz).1718# 10.4.21920## Bugfixes
848 unmodified lines