Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-143241: Fix infinite loop in zoneinfo._common.load_data#143243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
picnixz merged 10 commits intopython:mainfromfatihhcelik:fix-zoneinfo-infinite-loop
Dec 28, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
10 commits
Select commitHold shift + click to select a range
be21254
gh-143241: Fix infinite loop DoS in zoneinfo._common.load_data
fatihhcelikDec 28, 2025
a240d3a
📜🤖 Added by blurb_it.
blurb-it[bot]Dec 28, 2025
4b7f241
Update Lib/test/test_zoneinfo/test_zoneinfo.py
fatihhcelikDec 28, 2025
3691e9a
Update Lib/test/test_zoneinfo/test_zoneinfo.py
fatihhcelikDec 28, 2025
d6f950f
📜🤖 Added by blurb_it.
blurb-it[bot]Dec 28, 2025
7f46a5b
Apply suggestions from code review
fatihhcelikDec 28, 2025
ddd029b
gh-143241: Document ValueError for invalid files in ZoneInfo.from_file
fatihhcelikDec 28, 2025
79042d2
Delete Misc/NEWS.d/next/Library/2025-12-28-12-38-53.gh-issue-143241.y…
fatihhcelikDec 28, 2025
c2b00dc
Update Misc/NEWS.d/next/Library/2025-12-28-13-49-06.gh-issue-143241.5…
fatihhcelikDec 28, 2025
af90693
gh-143241: Add Patch by credit to NEWS
fatihhcelikDec 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletionsDoc/library/zoneinfo.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -206,6 +206,9 @@ The ``ZoneInfo`` class has two alternate constructors:

Objects created via this constructor cannot be pickled (see `pickling`_).

:exc:`ValueError` is raised if the data read from *file_obj* is not a valid
TZif file.

..classmethod::ZoneInfo.no_cache(key)

An alternate constructor that bypasses the constructor's cache. It is
Expand Down
2 changes: 2 additions & 0 deletionsLib/test/test_zoneinfo/test_zoneinfo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -252,6 +252,8 @@ def test_bad_zones(self):
bad_zones = [
b"", # Empty file
b"AAAA3" + b" " * 15, # Bad magic
# Truncated V2 file (should not loop indefinitely)
b"TZif2" + (b"\x00" * 39) + b"TZif2" + (b"\x00" * 39) + b"\n" + b"Part",
]

for bad_zone in bad_zones:
Expand Down
9 changes: 4 additions & 5 deletionsLib/zoneinfo/_common.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -118,11 +118,10 @@ def get_abbr(idx):
c = fobj.read(1) # Should be \n
assert c == b"\n", c

tz_bytes = b""
while (c := fobj.read(1)) != b"\n":
tz_bytes += c

tz_str = tz_bytes
line = fobj.readline()
if not line.endswith(b"\n"):
raise ValueError("Invalid TZif file: unexpected end of file")
tz_str = line.rstrip(b"\n")
else:
tz_str = None

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
:mod:`zoneinfo`: fix infinite loop in :meth:`ZoneInfo.from_file
<zoneinfo.ZoneInfo.from_file>` when parsing a malformed TZif file. Patch by Fatih Celik.
Loading

[8]ページ先頭

©2009-2026 Movatter.jp