Skip to content

gh-156939: Detect buffer overflow in bytes and bytearray - #157529

Merged
vstinner merged 6 commits into
python:mainfrom
vstinner:bytearray_overflow
Sep 15, 2026
Merged

vstinner merged 6 commits into
python:mainfrom
vstinner:bytearray_overflow

Conversation

@vstinner

@vstinner vstinner commented Sep 14, 2026

Copy link
Copy Markdown
Member

When Python is built in debug mode, bytes an bytearray destructors now check if the trailing null byte has been overridden to detect overflow. Add bytes_dealloc() to implement the check.

When Python is built in debug mode, bytes an bytearray destructors
now check if the trailing null byte has been overridden to detect
overflow. Add bytes_dealloc() to implement the check.
Comment thread Objects/bytearrayobject.c
@vstinner

Copy link
Copy Markdown
Member Author

"Tests / CIFuzz / cpython3 (address)" failed with a network failure. Since the job is not mandatory, I ignore it for now.

2026-09-15 13:42:11,991 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
...
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

@vstinner
vstinner merged commit 2d1007f into python:main Sep 15, 2026
53 of 54 checks passed
@vstinner
vstinner deleted the bytearray_overflow branch September 15, 2026 14:34
@vstinner

Copy link
Copy Markdown
Member Author

Merged. Thanks for the review @cmaloney.

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.

2 participants