]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 70056 via svnmerge from
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Sat, 28 Feb 2009 12:21:53 +0000 (12:21 +0000)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Sat, 28 Feb 2009 12:21:53 +0000 (12:21 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r70056 | hirokazu.yamamoto | 2009-02-28 21:13:07 +0900 | 2 lines

  Issue #1733986: Fixed mmap crash in accessing elements of second map object
  with same tagname but larger size than first map. (Windows)
........

Lib/test/test_mmap.py
Misc/NEWS
Modules/mmapmodule.c

index 59b2374ac26310abfe1853d01bcf40bec68c7905..73982270f07c07791403ff6f7e8664413874fa1f 100644 (file)
@@ -504,6 +504,34 @@ class MmapTests(unittest.TestCase):
         m.seek(8)
         self.assertRaises(ValueError, m.write, b"bar")
 
+    if os.name == 'nt':
+        def test_tagname(self):
+            data1 = b"0123456789"
+            data2 = b"abcdefghij"
+            assert len(data1) == len(data2)
+            # Test same tag
+            m1 = mmap.mmap(-1, len(data1), tagname="foo")
+            m1[:] = data1
+            m2 = mmap.mmap(-1, len(data2), tagname="foo")
+            m2[:] = data2
+            self.assertEquals(m1[:], data2)
+            self.assertEquals(m2[:], data2)
+            # Test differnt tag
+            m1 = mmap.mmap(-1, len(data1), tagname="foo")
+            m1[:] = data1
+            m2 = mmap.mmap(-1, len(data2), tagname="boo")
+            m2[:] = data2
+            self.assertEquals(m1[:], data1)
+            self.assertEquals(m2[:], data2)
+
+        def test_tagname_crash(self):
+            # Should not crash (Issue 1733986)
+            m = mmap.mmap(-1, 1000, tagname="foo")
+            try:
+                mmap.mmap(-1, 5000, tagname="foo")[:] # same tagname, but larger size
+            except:
+                pass
+
 
 def test_main():
     run_unittest(MmapTests)
index ff271b98236ba8e867850f39ba34ebe0988d2010..7f5a99b16227c37a8d03b4b4d694259f9056a284 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -173,6 +173,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #1733986: Fixed mmap crash in accessing elements of second map object
+  with same tagname but larger size than first map. (Windows)
+
 - Issue #5386: mmap.write_byte didn't check map size, so it could cause buffer
   overrun.
 
index db944066034cea77144701ec3cddc3a37ec291c3..d214b62cc4fa2368d33842ff9496f1c3c7214729 100644 (file)
@@ -1297,7 +1297,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
                                                     dwDesiredAccess,
                                                     off_hi,
                                                     off_lo,
-                                                    0);
+                                                    m_obj->size);
                if (m_obj->data != NULL)
                        return (PyObject *)m_obj;
                else