mirror of https://github.com/python/cpython
Patch #2111: Avoid mmap segfault when modifying a PROT_READ block.
This commit is contained in:
parent
0812de63c2
commit
5212da1b96
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue