Commit 0049249d authored by Antoine Pitrou's avatar Antoine Pitrou

Issue #8734: Avoid crash in msvcrt.get_osfhandle() when an invalid file

descriptor is provided.  Patch by Pascal Chambon.
parent 7d6e076f
......@@ -309,6 +309,9 @@ class OtherFileTests(unittest.TestCase):
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
......
......@@ -100,6 +100,9 @@ Core and Builtins
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.
......
......@@ -143,6 +143,9 @@ msvcrt_get_osfhandle(PyObject *self, PyObject *args)
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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment