[Python-checkins] r69714 - in python/trunk: Lib/test/test_mmap.py Misc/NEWS Modules/mmapmodule.c
hirokazu.yamamoto
python-checkins at python.org
Tue Feb 17 11:12:10 CET 2009
Author: hirokazu.yamamoto
Date: Tue Feb 17 11:12:10 2009
New Revision: 69714
Log:
Issue #5292: Fixed mmap crash on its boundary access m[len(m)].
Modified:
python/trunk/Lib/test/test_mmap.py
python/trunk/Misc/NEWS
python/trunk/Modules/mmapmodule.c
Modified: python/trunk/Lib/test/test_mmap.py
==============================================================================
--- python/trunk/Lib/test/test_mmap.py (original)
+++ python/trunk/Lib/test/test_mmap.py Tue Feb 17 11:12:10 2009
@@ -41,6 +41,10 @@
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'
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Tue Feb 17 11:12:10 2009
@@ -159,6 +159,8 @@
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.
Modified: python/trunk/Modules/mmapmodule.c
==============================================================================
--- python/trunk/Modules/mmapmodule.c (original)
+++ python/trunk/Modules/mmapmodule.c Tue Feb 17 11:12:10 2009
@@ -731,7 +731,7 @@
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 @@
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;
More information about the Python-checkins
mailing list