mirror of
https://github.com/python/cpython.git
synced 2025-11-02 14:41:33 +00:00
[3.14] gh-127971: fix off-by-one read beyond the end of a string during search (GH-132574) (#136628)
gh-127971: fix off-by-one read beyond the end of a string during search (GH-132574)
(cherry picked from commit 85ec3b3b50)
Co-authored-by: Duane Griffin <duaneg@dghda.com>
This commit is contained in:
parent
ed1e0cdc58
commit
348e22cf06
3 changed files with 14 additions and 4 deletions
|
|
@ -767,6 +767,15 @@ def test_replace(self):
|
|||
self.checkraises(TypeError, 'hello', 'replace', 42, 'h')
|
||||
self.checkraises(TypeError, 'hello', 'replace', 'h', 42)
|
||||
|
||||
def test_replacement_on_buffer_boundary(self):
|
||||
# gh-127971: Check we don't read past the end of the buffer when a
|
||||
# potential match misses on the last character.
|
||||
any_3_nonblank_codepoints = '!!!'
|
||||
seven_codepoints = any_3_nonblank_codepoints + ' ' + any_3_nonblank_codepoints
|
||||
a = (' ' * 243) + seven_codepoints + (' ' * 7)
|
||||
b = ' ' * 6 + chr(256)
|
||||
a.replace(seven_codepoints, b)
|
||||
|
||||
def test_replace_uses_two_way_maxcount(self):
|
||||
# Test that maxcount works in _two_way_count in fastsearch.h
|
||||
A, B = "A"*1000, "B"*1000
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue