Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ef517676
Commit
ef517676
authored
Feb 04, 2017
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Plain Diff
Issue #29444: Fixed out-of-bounds buffer access in the group() method of
the match object. Based on patch by WGH.
parents
26581785
86e42376
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
2 deletions
+20
-2
Lib/test/test_re.py
Lib/test/test_re.py
+10
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_sre.c
Modules/_sre.c
+7
-2
No files found.
Lib/test/test_re.py
View file @
ef517676
...
...
@@ -1821,6 +1821,16 @@ SUBPATTERN None 0 0
warnings.simplefilter('error', BytesWarning)
self.assertNotEqual(pattern3, pattern1)
def test_bug_29444(self):
s = bytearray(b'abcdefgh')
m = re.search(b'[a-h]+', s)
m2 = re.search(b'[e-h]+', s)
self.assertEqual(m.group(), b'abcdefgh')
self.assertEqual(m2.group(), b'efgh')
s[:] = b'xyz'
self.assertEqual(m.group(), b'xyz')
self.assertEqual(m2.group(), b'')
class PatternReprTests(unittest.TestCase):
def check(self, pattern, expected):
...
...
Misc/NEWS
View file @
ef517676
...
...
@@ -223,6 +223,9 @@ Extension Modules
Library
-------
-
Issue
#
29444
:
Fixed
out
-
of
-
bounds
buffer
access
in
the
group
()
method
of
the
match
object
.
Based
on
patch
by
WGH
.
-
Issue
#
29377
:
Add
SlotWrapperType
,
MethodWrapperType
,
and
MethodDescriptorType
built
-
in
types
to
types
module
.
Original
patch
by
Manuel
Krebber
.
...
...
Modules/_sre.c
View file @
ef517676
...
...
@@ -1945,6 +1945,7 @@ match_getslice_by_index(MatchObject* self, Py_ssize_t index, PyObject* def)
Py_buffer
view
;
PyObject
*
result
;
void
*
ptr
;
Py_ssize_t
i
,
j
;
if
(
index
<
0
||
index
>=
self
->
groups
)
{
/* raise IndexError if we were given a bad group number */
...
...
@@ -1966,8 +1967,12 @@ match_getslice_by_index(MatchObject* self, Py_ssize_t index, PyObject* def)
ptr
=
getstring
(
self
->
string
,
&
length
,
&
isbytes
,
&
charsize
,
&
view
);
if
(
ptr
==
NULL
)
return
NULL
;
result
=
getslice
(
isbytes
,
ptr
,
self
->
string
,
self
->
mark
[
index
],
self
->
mark
[
index
+
1
]);
i
=
self
->
mark
[
index
];
j
=
self
->
mark
[
index
+
1
];
i
=
Py_MIN
(
i
,
length
);
j
=
Py_MIN
(
j
,
length
);
result
=
getslice
(
isbytes
,
ptr
,
self
->
string
,
i
,
j
);
if
(
isbytes
&&
view
.
buf
!=
NULL
)
PyBuffer_Release
(
&
view
);
return
result
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment