Skip to content

fix(tz): reject TZ offset hour of 24 to avoid FixedOffset overflow#1787

Merged
djc merged 1 commit into
chronotope:mainfrom
SAY-5:fix-tz-offset-hour-overflow
May 25, 2026
Merged

fix(tz): reject TZ offset hour of 24 to avoid FixedOffset overflow#1787
djc merged 1 commit into
chronotope:mainfrom
SAY-5:fix-tz-offset-hour-overflow

Conversation

@SAY-5

@SAY-5 SAY-5 commented May 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #1480.

parse_offset in the POSIX TZ string parser accepted an offset hour of 24 (0..=24). A 24-hour offset is 86400 seconds, which does not fit in a FixedOffset (limited to ±23:59:59 / ±86399 seconds), so a TZ string such as pBB24 parsed successfully but later panicked when the offset was converted to a FixedOffset.

This caps the offset hour at 23, matching the FixedOffset range, so an out-of-range offset is rejected at parse time with InvalidTzString instead of panicking downstream.

This change is semver-compatible, so it targets main.

Added test_invalid_offset_hour covering hour 24 (with and without sign) and the maximum valid 23:59:59 offset.

@codecov

codecov Bot commented May 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.88%. Comparing base (c6063e6) to head (87bfa8f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1787      +/-   ##
==========================================
+ Coverage   89.86%   89.88%   +0.01%     
==========================================
  Files          35       35              
  Lines       13769    13775       +6     
==========================================
+ Hits        12374    12381       +7     
+ Misses       1395     1394       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@djc djc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

@djc djc merged commit f14ead4 into chronotope:main May 25, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic with TZ="pBB24"

2 participants