Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
887afac
fix: bytearray: prevent UAF in search-like methods by exporting self …
fatelei Dec 11, 2025
2dd958b
chore: add blurb
fatelei Dec 11, 2025
2cb388b
fix: fix new format
fatelei Dec 11, 2025
b954fc7
fix: fix python lint error and make code more simple
fatelei Dec 12, 2025
87b5cce
fix: fix code not regenerate
fatelei Dec 12, 2025
f1b7596
fix: fix ubuntu test failed for ass_subscript2
fatelei Dec 12, 2025
13a6469
chore: add comment for method test_search_methods_reentrancy_raises_b…
fatelei Dec 12, 2025
b5efa3f
refactor: refactor test_search_methods_reentrancy_raises_buffererror …
fatelei Dec 12, 2025
62b2801
fix: fix pre commit failed
fatelei Dec 12, 2025
8419650
chore: using subTest to distinguish which method failed
fatelei Dec 12, 2025
2df5acb
chore: using more light operation instead of heavy operation
fatelei Dec 12, 2025
e6c622e
fix: fix pre-commit error
fatelei Dec 12, 2025
7964033
chore: resolve comment
fatelei Dec 15, 2025
8b1cea2
chore: resolve comment
fatelei Dec 15, 2025
782cab1
chore: update the news
fatelei Dec 15, 2025
14963ea
chore: bytearray_contains add Py_BEGIN_CRITICAL_SECTION back
fatelei Dec 15, 2025
87225ad
fix: fix build failed
fatelei Dec 15, 2025
4214d56
chore: resolve comment
fatelei Dec 15, 2025
01fcc68
fix: fix pre commit error
fatelei Dec 15, 2025
6a58ffe
fix: fix news format
fatelei Dec 15, 2025
abb9fb7
fix: fix news format
fatelei Dec 15, 2025
81a611d
chore: change args order
fatelei Dec 18, 2025
fb25b7d
fix: bytearray: prevent UAF in search-like methods by exporting self …
fatelei Dec 11, 2025
176bcb2
chore: add blurb
fatelei Dec 11, 2025
ca7f893
fix: fix new format
fatelei Dec 11, 2025
e4bdc6c
fix: fix python lint error and make code more simple
fatelei Dec 12, 2025
c8905e3
fix: fix code not regenerate
fatelei Dec 12, 2025
9d2e801
fix: fix ubuntu test failed for ass_subscript2
fatelei Dec 12, 2025
b816ac7
chore: add comment for method test_search_methods_reentrancy_raises_b…
fatelei Dec 12, 2025
ac5bf09
refactor: refactor test_search_methods_reentrancy_raises_buffererror …
fatelei Dec 12, 2025
09b5edf
fix: fix pre commit failed
fatelei Dec 12, 2025
70507f0
chore: using subTest to distinguish which method failed
fatelei Dec 12, 2025
f1ddb09
chore: using more light operation instead of heavy operation
fatelei Dec 12, 2025
8c12c99
fix: fix pre-commit error
fatelei Dec 12, 2025
fa2f4a7
chore: resolve comment
fatelei Dec 15, 2025
db79ab3
chore: resolve comment
fatelei Dec 15, 2025
a1d1d66
chore: update the news
fatelei Dec 15, 2025
f7583b2
chore: bytearray_contains add Py_BEGIN_CRITICAL_SECTION back
fatelei Dec 15, 2025
d217984
fix: fix build failed
fatelei Dec 15, 2025
8d3e0de
chore: resolve comment
fatelei Dec 15, 2025
fab4b60
fix: fix pre commit error
fatelei Dec 15, 2025
08c6159
fix: fix news format
fatelei Dec 15, 2025
13c110d
fix: fix news format
fatelei Dec 15, 2025
8d04ec3
chore: change args order
fatelei Dec 18, 2025
bed7f4d
feat: contains, split, rsplit using ob_exports
fatelei Dec 18, 2025
f48c2d1
fix: fix git conflict
fatelei Dec 18, 2025
ade13be
Merge remote-tracking branch 'upstream/main' into issue-142495
fatelei Dec 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: refactor test_search_methods_reentrancy_raises_buffererror …
…make it more readable
  • Loading branch information
fatelei committed Dec 12, 2025
commit b5efa3f66294a8041d0817144c5c39b2b8f7bd4c
26 changes: 13 additions & 13 deletions Lib/test/test_bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2062,21 +2062,21 @@ def __index__(self):

def test_search_methods_reentrancy_raises_buffererror(self):
# gh-142560: Raise BufferError if buffer mutates during search arg conversion.
ba = bytearray(b"A")
class Evil:
def __init__(self, ba):
self.ba = ba
def __index__(self):
ba.clear()
return 65 # ord('A')
with self.assertRaises(BufferError):
ba.find(Evil())
with self.assertRaises(BufferError):
ba.count(Evil())
with self.assertRaises(BufferError):
ba.index(Evil())
with self.assertRaises(BufferError):
ba.rindex(Evil())
with self.assertRaises(BufferError):
ba.rfind(Evil())
self.ba.clear()
return 65

def make_case():
ba = bytearray(b"A")
return ba, Evil(ba)

for name in ("find", "count", "index", "rindex", "rfind"):
ba, evil = make_case()
with self.assertRaises(BufferError):
getattr(ba, name)(evil)


class AssortedBytesTest(unittest.TestCase):
Expand Down
Loading