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
f6bbd0e7
Commit
f6bbd0e7
authored
Feb 17, 2009
by
Hirokazu Yamamoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #5292: Fixed mmap crash on its boundary access m[len(m)].
parent
f68b5b80
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
2 deletions
+8
-2
Lib/test/test_mmap.py
Lib/test/test_mmap.py
+4
-0
Misc/NEWS
Misc/NEWS
+2
-0
Modules/mmapmodule.c
Modules/mmapmodule.c
+2
-2
No files found.
Lib/test/test_mmap.py
View file @
f6bbd0e7
...
...
@@ -41,6 +41,10 @@ class MmapTests(unittest.TestCase):
self
.
assertEqual
(
m
[
0
],
'
\
0
'
)
self
.
assertEqual
(
m
[
0
:
3
],
'
\
0
\
0
\
0
'
)
# Shouldn't crash on boundary (Issue #5292)
self
.
assertRaises
(
IndexError
,
m
.
__getitem__
,
len
(
m
))
self
.
assertRaises
(
IndexError
,
m
.
__setitem__
,
len
(
m
),
'
\
0
'
)
# Modify the file's content
m
[
0
]
=
'3'
m
[
PAGESIZE
+
3
:
PAGESIZE
+
3
+
3
]
=
'bar'
...
...
Misc/NEWS
View file @
f6bbd0e7
...
...
@@ -159,6 +159,8 @@ Core and Builtins
Library
-------
- Issue #5292: Fixed mmap crash on its boundary access m[len(m)].
- Issue #2279: distutils.sdist.add_defaults now add files
from the package_data and the data_files metadata.
...
...
Modules/mmapmodule.c
View file @
f6bbd0e7
...
...
@@ -731,7 +731,7 @@ mmap_subscript(mmap_object *self, PyObject *item)
return
NULL
;
if
(
i
<
0
)
i
+=
self
->
size
;
if
(
i
<
0
||
(
size_t
)
i
>
self
->
size
)
{
if
(
i
<
0
||
(
size_t
)
i
>
=
self
->
size
)
{
PyErr_SetString
(
PyExc_IndexError
,
"mmap index out of range"
);
return
NULL
;
...
...
@@ -872,7 +872,7 @@ mmap_ass_subscript(mmap_object *self, PyObject *item, PyObject *value)
return
-
1
;
if
(
i
<
0
)
i
+=
self
->
size
;
if
(
i
<
0
||
(
size_t
)
i
>
self
->
size
)
{
if
(
i
<
0
||
(
size_t
)
i
>
=
self
->
size
)
{
PyErr_SetString
(
PyExc_IndexError
,
"mmap index out of range"
);
return
-
1
;
...
...
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