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-91153: Fix bytearray holding a reference to its internal buffer when calling into potentially mutating __index__ methods#132379

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

Open
bast0006 wants to merge5 commits intopython:main
base:main
Choose a base branch
Loading
frombast0006:bast0006/gh-91153

Conversation

bast0006
Copy link

@bast0006bast0006 commentedApr 10, 2025
edited by bedevere-appbot
Loading

bytearray's__setitem__ implementation currently grabs a reference to its internal buffer before calling_getbyvalue to determine the index that needs assignment._getbyvalue can call into arbitrary python code via__index__ dunders, which could alter the internal buffer and leave said reference dangling.

A prior fix for this issue ensures that bounds checking occurs after_getbyvalue is called. However, python code is capable of resizing the bytearray, resulting in limited but still broken behavior.

This patch ensures that the reference to the internal buffer is fetched only after_getbyvalue is called to prevent it from being held while any python code is run.

@python-cla-bot
Copy link

python-cla-botbot commentedApr 10, 2025
edited
Loading

All commit authors signed the Contributor License Agreement.

CLA signed

bast0006 reacted with thumbs up emoji

@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

@bast0006
Copy link
Author

bast0006 commentedApr 10, 2025
edited
Loading

I've signed the CLA. Let me know if a NEWS entry is required. I'm not sure it is, especially since there was already a previous change that this is a fix to.

@picnixzpicnixz self-requested a reviewMay 17, 2025 11:00
Copy link
Member

@picnixzpicnixz left a comment
edited
Loading

Choose a reason for hiding this comment

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

Can you add a NEWS entry please? It's still worth to mention that we fixed more crashes.

@bast0006
Copy link
Author

Done

@bast0006bast0006 requested a review frompicnixzMay 17, 2025 23:25
@ZeroIntensityZeroIntensity added needs backport to 3.13bugs and security fixes needs backport to 3.14bugs and security fixes labelsMay 18, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ZeroIntensityZeroIntensityZeroIntensity left review comments

@picnixzpicnixzAwaiting requested review from picnixz

Assignees
No one assigned
Labels
awaiting reviewneeds backport to 3.13bugs and security fixesneeds backport to 3.14bugs and security fixes
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@bast0006@picnixz@ZeroIntensity

[8]ページ先頭

©2009-2025 Movatter.jp