From b6aba6a40666c469e28619455a2b19baba4efcef Mon Sep 17 00:00:00 2001 From: Paul Dicker Date: Sat, 2 Mar 2024 22:08:37 +0100 Subject: [PATCH] Limit TZ string to 23:59:59 offsets --- src/offset/local/tz_info/rule.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/offset/local/tz_info/rule.rs b/src/offset/local/tz_info/rule.rs index 0ff4fe7bde..3371d6ab08 100644 --- a/src/offset/local/tz_info/rule.rs +++ b/src/offset/local/tz_info/rule.rs @@ -364,7 +364,10 @@ fn parse_name<'a>(cursor: &mut Cursor<'a>) -> Result<&'a [u8], Error> { fn parse_offset(cursor: &mut Cursor) -> Result { let (sign, hour, minute, second) = parse_signed_hhmmss(cursor)?; - if !(0..=24).contains(&hour) { + // POSIX allows offsets of up to 24:59:59. + // However in chrono we limit offsets to 23:59:59, which is already much more than the 14 hours + // largest offsets that see some real-world use. + if !(0..=23).contains(&hour) { return Err(Error::InvalidTzString("invalid offset hour")); } if !(0..=59).contains(&minute) {