From 686ee4fd3db413b24c49e5a6331d3ba5fb5d9b05 Mon Sep 17 00:00:00 2001 From: Brian Curtin Date: Sun, 1 Aug 2010 15:44:11 +0000 Subject: Merged revisions 83407 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83407 | brian.curtin | 2010-08-01 10:26:26 -0500 (Sun, 01 Aug 2010) | 3 lines Fix #8105. Add validation to mmap.mmap so invalid file descriptors don't cause a crash on Windows. ........ --- Lib/test/test_mmap.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'Lib/test') diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index eae4157edc..b3869a6317 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -1,6 +1,6 @@ from test.support import TESTFN, run_unittest, import_module import unittest -import os, re, itertools +import os, re, itertools, socket # Skip test if we can't import mmap. mmap = import_module('mmap') @@ -586,6 +586,16 @@ class MmapTests(unittest.TestCase): pass m.close() + def test_invalid_descriptor(self): + # socket file descriptors are valid, but out of range + # for _get_osfhandle, causing a crash when validating the + # parameters to _get_osfhandle. + s = socket.socket() + try: + with self.assertRaises(mmap.error): + m = mmap.mmap(s.fileno(), 10) + finally: + s.close() def test_main(): run_unittest(MmapTests) -- cgit v1.2.1