Skip to content

Commit

Permalink
Fix overflow issue in hour check for timedelta (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
sydney-runkle committed Jun 26, 2024
1 parent 0aa56ea commit a036efb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "speedate"
authors = ["Samuel Colvin <s@muelcolvin.com>"]
version = "0.14.2"
version = "0.14.3"
edition = "2021"
description = "Fast and simple datetime, date, time and duration parsing"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion src/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ impl Duration {
}

for byte in hour_part {
let h = *byte - b'0';
let h = byte.wrapping_sub(b'0');
if h > 9 {
return Err(ParseError::InvalidCharHour);
}
Expand Down
1 change: 1 addition & 0 deletions tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,7 @@ param_tests! {
duration_time_invalid_over_limit_hour: err => "100000000000:01:03", DurationHourValueTooLarge;
duration_time_overflow_hour: err => "100000000000000000000000:01:03", DurationHourValueTooLarge;
duration_time_invalid_format_hour: err => "1000xxx000:01:03", InvalidCharHour;
duration_time_invalid_format_hour2: err => "1 10:10", InvalidCharHour;
duration_time_invalid_minute: err => "00:60:03", OutOfRangeMinute;
duration_time_invalid_second: err => "00:00:60", OutOfRangeSecond;
duration_time_fraction_too_long: err => "00:00:00.1234567", SecondFractionTooLong;
Expand Down

0 comments on commit a036efb

Please sign in to comment.