Skip to content

Commit

Permalink
Check for invalid cast
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Feb 24, 2024
1 parent fda69d1 commit c5f6189
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/naive/datetime/serde.rs
Expand Up @@ -972,7 +972,11 @@ pub mod ts_seconds {
where
E: de::Error,
{
NaiveDateTime::from_timestamp_opt(value as i64, 0).ok_or_else(|| invalid_ts(value))
if value > i64::MAX as u64 {
Err(invalid_ts(value))

Check warning on line 976 in src/naive/datetime/serde.rs

View check run for this annotation

Codecov / codecov/patch

src/naive/datetime/serde.rs#L976

Added line #L976 was not covered by tests
} else {
NaiveDateTime::from_timestamp_opt(value as i64, 0).ok_or_else(|| invalid_ts(value))
}
}
}
}
Expand Down Expand Up @@ -1104,7 +1108,7 @@ pub mod ts_seconds_option {
}
}

pub(crate) enum SerdeError<T: fmt::Display> {
enum SerdeError<T: fmt::Display> {
InvalidTimestamp(T),
}

Expand Down

0 comments on commit c5f6189

Please sign in to comment.