gh-144872: fix heap buffer overflow _PyTokenizer_ensure_utf8#144807
Conversation
Signed-off-by: Adam <adam@Adam-Workstation.lan>
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Sorry, something went wrong.
|
Thanks for the contribution! Would you mind adding a regression test for this in https://github.com/python/cpython/blob/main/Lib/test/test_tokenize.py |
Sorry, something went wrong.
Add a test covering truncated multi-byte UTF-8 sequences at end of input. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Sorry, something went wrong.
|
I added a test. (discussed with PSRT) We're not considering this a security issue, |
Sorry, something went wrong.
|
We do like to have issues filed to track things - read up on https://devguide.python.org/getting-started/pull-request-lifecycle/#pullrequest while you're working on already public oss-fuzz findings, as they are public it is fine to go ahead and make public PRs. But if you come across any that seem actually security relevant, please reach out via email to the to PSRT, or since you're producing fix PRs maybe just use https://github.com/python/cpython/security to drop those in GHSA's for us to look over (many will probably be things we just open directly to the public as a non-concern "more of a bug" like this one) |
Sorry, something went wrong.
Signed-off-by: Adam Korczynski <adam@adalogics.com>
Sorry, something went wrong.
…9_Q30.rst Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: AN Long <aisk@users.noreply.github.com>
|
@aisk thank you, is it me or you who needs to sign the CLA? |
Sorry, something went wrong.
it was me. |
Sorry, something went wrong.
pablogsal
left a comment
There was a problem hiding this comment.
LGTM
I moved the news entry to Core. THanks a lot for the great work @AdamKorcz 🚀
Sorry, something went wrong.
3fc945d
into
python:main
Feb 26, 2026
|
Thanks @AdamKorcz for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
Sorry, something went wrong.
…ythonGH-144807) (cherry picked from commit 3fc945d) Co-authored-by: AdamKorcz <44787359+AdamKorcz@users.noreply.github.com>
|
Sorry, @AdamKorcz and @pablogsal, I could not cleanly backport this to |
Sorry, something went wrong.
…GH-144807) (#145287) Co-authored-by: AdamKorcz <44787359+AdamKorcz@users.noreply.github.com>
|
@AdamKorcz can you do the 3.13 backport following #144807 (comment) ? |
Sorry, something went wrong.
…_utf8` (pythonGH-144807) (cherry picked from commit 3fc945d) Co-authored-by: AdamKorcz <44787359+AdamKorcz@users.noreply.github.com>
…GH-144807) (#145441) (cherry picked from commit 3fc945d) Co-authored-by: AdamKorcz <44787359+AdamKorcz@users.noreply.github.com>
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot ARM64 MacOS M1 NoGIL 3.13 (tier-2) has failed when building commit 5577bd1. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/1408/builds/1843 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "/Users/buildbot/buildarea/3.13.itamaro-macos-arm64-aws.macos-with-brew.nogil/build/Lib/test/test_concurrent_futures/executor.py", line 147, in test_free_reference
for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/buildbot/buildarea/3.13.itamaro-macos-arm64-aws.macos-with-brew.nogil/build/Lib/test/support/__init__.py", line 2596, in sleeping_retry
for _ in busy_retry(timeout, err_msg, error=error):
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/buildbot/buildarea/3.13.itamaro-macos-arm64-aws.macos-with-brew.nogil/build/Lib/test/support/__init__.py", line 2566, in busy_retry
raise AssertionError(msg)
AssertionError: timeout (45.9 seconds)
Traceback (most recent call last):
File "/Users/buildbot/buildarea/3.13.itamaro-macos-arm64-aws.macos-with-brew.nogil/build/Lib/test/test_concurrent_futures/executor.py", line 147, in test_free_reference
for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/buildbot/buildarea/3.13.itamaro-macos-arm64-aws.macos-with-brew.nogil/build/Lib/test/support/__init__.py", line 2596, in sleeping_retry
for _ in busy_retry(timeout, err_msg, error=error):
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/buildbot/buildarea/3.13.itamaro-macos-arm64-aws.macos-with-brew.nogil/build/Lib/test/support/__init__.py", line 2566, in busy_retry
raise AssertionError(msg)
AssertionError: timeout (45.8 seconds)
Traceback (most recent call last):
File "/Users/buildbot/buildarea/3.13.itamaro-macos-arm64-aws.macos-with-brew.nogil/build/Lib/test/test_httpservers.py", line 1028, in test_large_content_length_truncated
res = self.request('/cgi-bin/file1.py', 'POST', b'x', headers)
File "/Users/buildbot/buildarea/3.13.itamaro-macos-arm64-aws.macos-with-brew.nogil/build/Lib/test/test_httpservers.py", line 89, in request
return self.connection.getresponse()
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/Users/buildbot/buildarea/3.13.itamaro-macos-arm64-aws.macos-with-brew.nogil/build/Lib/http/client.py", line 1450, in getresponse
response.begin()
~~~~~~~~~~~~~~^^
File "/Users/buildbot/buildarea/3.13.itamaro-macos-arm64-aws.macos-with-brew.nogil/build/Lib/http/client.py", line 336, in begin
version, status, reason = self._read_status()
~~~~~~~~~~~~~~~~~^^
File "/Users/buildbot/buildarea/3.13.itamaro-macos-arm64-aws.macos-with-brew.nogil/build/Lib/http/client.py", line 297, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
File "/Users/buildbot/buildarea/3.13.itamaro-macos-arm64-aws.macos-with-brew.nogil/build/Lib/socket.py", line 719, in readinto
return self._sock.recv_into(b)
~~~~~~~~~~~~~~~~~~~~^^^
ConnectionResetError: [Errno 54] Connection reset by peer
|
Sorry, something went wrong.
Fixes https://issues.oss-fuzz.com/issues/451112368 and #144872
cc @ammaraskar
_PyTokenizer_ensure_utf8#144872