[Python-checkins] r63561 - in python/branches/release25-maint: Lib/test/test_mmap.py Misc/NEWS Modules/mmapmodule.c
martin.v.loewis
python-checkins at python.org
Fri May 23 16:30:44 CEST 2008
Author: martin.v.loewis
Date: Fri May 23 16:30:44 2008
New Revision: 63561
Log:
Patch #2111: Avoid mmap segfault when modifying a PROT_READ block.
Modified:
python/branches/release25-maint/Lib/test/test_mmap.py
python/branches/release25-maint/Misc/NEWS
python/branches/release25-maint/Modules/mmapmodule.c
Modified: python/branches/release25-maint/Lib/test/test_mmap.py
==============================================================================
--- python/branches/release25-maint/Lib/test/test_mmap.py (original)
+++ python/branches/release25-maint/Lib/test/test_mmap.py Fri May 23 16:30:44 2008
@@ -380,6 +380,23 @@
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)
Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS (original)
+++ python/branches/release25-maint/Misc/NEWS Fri May 23 16:30:44 2008
@@ -86,6 +86,8 @@
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.
Modified: python/branches/release25-maint/Modules/mmapmodule.c
==============================================================================
--- python/branches/release25-maint/Modules/mmapmodule.c (original)
+++ python/branches/release25-maint/Modules/mmapmodule.c Fri May 23 16:30:44 2008
@@ -881,6 +881,10 @@
"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 */
More information about the Python-checkins
mailing list