Skip to content

gh-161096: Reject invalid TZif abbreviation block sizes in zoneinfo - #161097

Merged
gpshead merged 1 commit into
python:mainfrom
gpshead:zoneinfo-charcnt-bound
Nov 1, 2026
Merged

gpshead merged 1 commit into
python:mainfrom
gpshead:zoneinfo-charcnt-bound

Conversation

@gpshead

@gpshead gpshead commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

load_data() now rejects a charcnt outside 0..512 with ValueError before reading the abbreviation block, next to the existing invalid transition index check from gh-145883. Abbreviation indexes are one octet, so a longer block cannot be addressed and only multiplies the per-index copies; tzcode's zic limits it to 50 bytes. The local time type's abbrind is also unpacked as unsigned so that indexes 128..255 resolve to the right abbreviation. Both ZoneInfo implementations parse through _common.load_data(), so no C change is needed.

Fixes #161096

ANT-2026-W7U7UDLT

…info

ZoneInfo.from_file() now raises ValueError for a negative charcnt or one
above 512, and reads the abbreviation index as unsigned.
@gpshead gpshead added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Nov 1, 2026
@gpshead gpshead self-assigned this Nov 1, 2026
@gpshead
gpshead marked this pull request as ready for review November 1, 2026 17:55
@gpshead
gpshead enabled auto-merge (squash) November 1, 2026 17:56
@gpshead
gpshead merged commit e9f37a3 into python:main Nov 1, 2026
62 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @gpshead for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@bedevere-app

bedevere-app Bot commented Nov 1, 2026

Copy link
Copy Markdown

GH-161122 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Nov 1, 2026
@bedevere-app

bedevere-app Bot commented Nov 1, 2026

Copy link
Copy Markdown

GH-161123 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Nov 1, 2026
gpshead added a commit that referenced this pull request Nov 1, 2026
…einfo (GH-161097) (#161123)

ZoneInfo.from_file() now raises ValueError for a negative charcnt or one
above 512, and reads the abbreviation index as unsigned.

ANT-2026-W7U7UDLT

(cherry picked from commit e9f37a3)
gpshead added a commit that referenced this pull request Nov 1, 2026
…einfo (GH-161097) (#161122)

ZoneInfo.from_file() now raises ValueError for a negative charcnt or one
above 512, and reads the abbreviation index as unsigned.

ANT-2026-W7U7UDLT

(cherry picked from commit e9f37a3)
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.

ZoneInfo.from_file() accepts any TZif charcnt and can use 512x the file size in memory

1 participant