mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.13] gh-140471: Fix buffer overflow in AST node initialization with malformed _fields (GH-140506) (#140510)
(cherry picked from commit 95953b692d)
This commit is contained in:
parent
adf0c11a26
commit
1cc2c954d6
4 changed files with 15 additions and 4 deletions
|
|
@ -3119,6 +3119,15 @@ class MoreFieldsThanTypes(ast.AST):
|
|||
self.assertEqual(obj.a, 1)
|
||||
self.assertEqual(obj.b, 2)
|
||||
|
||||
def test_malformed_fields_with_bytes(self):
|
||||
class BadFields(ast.AST):
|
||||
_fields = (b'\xff'*64,)
|
||||
_field_types = {'a': int}
|
||||
|
||||
# This should not crash
|
||||
with self.assertWarnsRegex(DeprecationWarning, r"Field b'\\xff\\xff.*' .*"):
|
||||
obj = BadFields()
|
||||
|
||||
def test_complete_field_types(self):
|
||||
class _AllFieldTypes(ast.AST):
|
||||
_fields = ("a", "b")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue