From b2a669bd335cd3c49aa3d42003405537d8ba98f6 Mon Sep 17 00:00:00 2001 From: Johannes Maibaum <maibaum@tonwelt.com> Date: Fri, 3 Jan 2020 10:04:58 +0100 Subject: [PATCH] Fix bounds check in `DateTime::from_time()` `::time::Tm.tm_mon` has number range [0, 11], see: https://docs.rs/time/0.1.42/time/struct.Tm.html#structfield.tm_mon --- src/types.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types.rs b/src/types.rs index 93cb03c1..29a089e1 100644 --- a/src/types.rs +++ b/src/types.rs @@ -111,7 +111,7 @@ impl DateTime { /// Returns `Err` when this object is out of bounds pub fn from_time(tm: ::time::Tm) -> Result<DateTime, ()> { if tm.tm_year >= 80 && tm.tm_year <= 207 - && tm.tm_mon >= 1 && tm.tm_mon <= 31 + && tm.tm_mon >= 0 && tm.tm_mon <= 11 && tm.tm_mday >= 1 && tm.tm_mday <= 31 && tm.tm_hour >= 0 && tm.tm_hour <= 23 && tm.tm_min >= 0 && tm.tm_min <= 59