[Python-checkins] r84506 - in python/branches/py3k: Lib/test/test_fileio.py Misc/NEWS PC/msvcrtmodule.c
antoine.pitrou
python-checkins at python.org
Sat Sep 4 22:53:30 CEST 2010
Author: antoine.pitrou
Date: Sat Sep 4 22:53:29 2010
New Revision: 84506
Log:
Issue #8734: Avoid crash in msvcrt.get_osfhandle() when an invalid file
descriptor is provided. Patch by Pascal Chambon.
Modified:
python/branches/py3k/Lib/test/test_fileio.py
python/branches/py3k/Misc/NEWS
python/branches/py3k/PC/msvcrtmodule.c
Modified: python/branches/py3k/Lib/test/test_fileio.py
==============================================================================
--- python/branches/py3k/Lib/test/test_fileio.py (original)
+++ python/branches/py3k/Lib/test/test_fileio.py Sat Sep 4 22:53:29 2010
@@ -309,6 +309,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/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Sat Sep 4 22:53:29 2010
@@ -100,6 +100,9 @@
Extensions
----------
+- 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/py3k/PC/msvcrtmodule.c
==============================================================================
--- python/branches/py3k/PC/msvcrtmodule.c (original)
+++ python/branches/py3k/PC/msvcrtmodule.c Sat Sep 4 22:53:29 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