Commit 5212da1b authored by Martin v. Löwis's avatar Martin v. Löwis

Patch #2111: Avoid mmap segfault when modifying a PROT_READ block.

parent 0812de63
......@@ -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)
......
......@@ -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.
......
......@@ -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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment