[Python-checkins] r84507 - in python/branches/release31-maint: Lib/test/test_fileio.py Misc/NEWS PC/msvcrtmodule.c

antoine.pitrou python-checkins at python.org
Sat Sep 4 23:02:41 CEST 2010


Author: antoine.pitrou
Date: Sat Sep  4 23:02:41 2010
New Revision: 84507

Log:
Merged revisions 84506 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r84506 | antoine.pitrou | 2010-09-04 22:53:29 +0200 (sam., 04 sept. 2010) | 5 lines
  
  Issue #8734: Avoid crash in msvcrt.get_osfhandle() when an invalid file
  descriptor is provided.  Patch by Pascal Chambon.
........


Modified:
   python/branches/release31-maint/   (props changed)
   python/branches/release31-maint/Lib/test/test_fileio.py
   python/branches/release31-maint/Misc/NEWS
   python/branches/release31-maint/PC/msvcrtmodule.c

Modified: python/branches/release31-maint/Lib/test/test_fileio.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_fileio.py	(original)
+++ python/branches/release31-maint/Lib/test/test_fileio.py	Sat Sep  4 23:02:41 2010
@@ -313,6 +313,9 @@
     def testInvalidFd(self):
         self.assertRaises(ValueError, _FileIO, -10)
         self.assertRaises(OSError, _FileIO, make_bad_fd())
+        if sys.platform == 'win32':
+            import msvcrt
+            self.assertRaises(IOError, msvcrt.get_osfhandle, make_bad_fd())
 
     def testBadModeArgument(self):
         # verify that we get a sensible error message for bad mode argument

Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS	(original)
+++ python/branches/release31-maint/Misc/NEWS	Sat Sep  4 23:02:41 2010
@@ -477,6 +477,9 @@
 Extension Modules
 -----------------
 
+- Issue #8734: Avoid crash in msvcrt.get_osfhandle() when an invalid file
+  descriptor is provided.  Patch by Pascal Chambon.
+
 - Issue #7736: Release the GIL around calls to opendir() and closedir()
   in the posix module.  Patch by Marcin Bachry.
 

Modified: python/branches/release31-maint/PC/msvcrtmodule.c
==============================================================================
--- python/branches/release31-maint/PC/msvcrtmodule.c	(original)
+++ python/branches/release31-maint/PC/msvcrtmodule.c	Sat Sep  4 23:02:41 2010
@@ -143,6 +143,9 @@
     if (!PyArg_ParseTuple(args,"i:get_osfhandle", &fd))
         return NULL;
 
+    if (!_PyVerify_fd(fd))
+        return PyErr_SetFromErrno(PyExc_IOError);
+
     handle = _get_osfhandle(fd);
     if (handle == -1)
         return PyErr_SetFromErrno(PyExc_IOError);


More information about the Python-checkins mailing list