Skip to content

Commit

Permalink
Merge branch 'fix-fuzz'
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Aug 3, 2024
2 parents e0420c0 + a729c4b commit 3604a3b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion gix-date/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ pub(crate) mod function {
}

Ok(if let Ok(val) = Date::strptime(SHORT.0, input) {
let val = val.to_zoned(TimeZone::UTC).expect("date is in range");
let val = val
.to_zoned(TimeZone::UTC)
.map_err(|_| Error::InvalidDateString { input: input.into() })?;
Time::new(val.timestamp().as_second(), val.offset().seconds())
} else if let Ok(val) = rfc2822_relaxed(input) {
Time::new(val.timestamp().as_second(), val.offset().seconds())
Expand Down
2 changes: 1 addition & 1 deletion gix-date/tests/time/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ mod relative {
mod fuzz {
#[test]
fn invalid_but_does_not_cause_panic() {
for input in ["7 -𬞋", "5 ڜ-09", "-4 week ago Z", "8960609 day ago"] {
for input in ["-9999-1-1", "7 -𬞋", "5 ڜ-09", "-4 week ago Z", "8960609 day ago"] {
let _ = gix_date::parse(input, Some(std::time::UNIX_EPOCH)).unwrap_err();
}
}
Expand Down

0 comments on commit 3604a3b

Please sign in to comment.