-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-143005: prevent incompatible __class__ reassignment for ctypes arrays #143907
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
gh-143005: prevent incompatible __class__ reassignment for ctypes arrays #143907
Conversation
59929a5 to
d17521c
Compare
|
@serhiy-storchaka |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your PR, @VanshAgarwal24036. I did not know what to do with this issue. It seems that adding check in tp_setattro is the way to go. But I suspect we need more tests -- each condition should be covered by alternate tests,
This PR fixes a heap buffer overflow in ctypes arrays caused by assigning
class to an incompatible array type.
The change rejects class reassignment when the new array type differs
in length, size, or element type, preventing out-of-bounds memory access.
A regression test is included.
__class__swap #143005