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
5212da1b
Commit
5212da1b
authored
May 23, 2008
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #2111: Avoid mmap segfault when modifying a PROT_READ block.
parent
0812de63
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
0 deletions
+23
-0
Lib/test/test_mmap.py
Lib/test/test_mmap.py
+17
-0
Misc/NEWS
Misc/NEWS
+2
-0
Modules/mmapmodule.c
Modules/mmapmodule.c
+4
-0
No files found.
Lib/test/test_mmap.py
View file @
5212da1b
...
...
@@ -380,6 +380,23 @@ def test_both():
finally
:
os
.
unlink
(
TESTFN
)
# Test that setting access to PROT_READ gives exception
# rather than crashing
if
hasattr
(
mmap
,
"PROT_READ"
):
try
:
mapsize
=
10
open
(
TESTFN
,
"wb"
).
write
(
"a"
*
mapsize
)
f
=
open
(
TESTFN
,
"rb"
)
m
=
mmap
.
mmap
(
f
.
fileno
(),
mapsize
,
prot
=
mmap
.
PROT_READ
)
try
:
m
.
write
(
"foo"
)
except
TypeError
:
pass
else
:
verify
(
0
,
"PROT_READ is not working"
)
finally
:
os
.
unlink
(
TESTFN
)
def
test_anon
():
print
" anonymous mmap.mmap(-1, PAGESIZE)..."
m
=
mmap
.
mmap
(
-
1
,
PAGESIZE
)
...
...
Misc/NEWS
View file @
5212da1b
...
...
@@ -86,6 +86,8 @@ Library
Extension
Modules
-----------------
-
Patch
#
2111
:
Avoid
mmap
segfault
when
modifying
a
PROT_READ
block
.
-
zlib
.
decompressobj
().
flush
(
value
)
no
longer
crashes
the
interpreter
when
passed
a
value
less
than
or
equal
to
zero
.
...
...
Modules/mmapmodule.c
View file @
5212da1b
...
...
@@ -881,6 +881,10 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
"mmap invalid access parameter."
);
}
if
(
prot
==
PROT_READ
)
{
access
=
ACCESS_READ
;
}
#ifdef HAVE_FSTAT
# ifdef __VMS
/* on OpenVMS we must ensure that all bytes are written to the file */
...
...
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