mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
Fix #8105. Add validation to mmap.mmap so invalid file descriptors
don't cause a crash on Windows.
This commit is contained in:
parent
0bccc185b4
commit
ea47eaa395
3 changed files with 19 additions and 1 deletions
|
|
@ -1236,6 +1236,11 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
|
|||
1);
|
||||
*/
|
||||
if (fileno != -1 && fileno != 0) {
|
||||
/* Ensure that fileno is within the CRT's valid range */
|
||||
if (_PyVerify_fd(fileno) == 0) {
|
||||
PyErr_SetFromErrno(mmap_module_error);
|
||||
return NULL;
|
||||
}
|
||||
fh = (HANDLE)_get_osfhandle(fileno);
|
||||
if (fh==(HANDLE)-1) {
|
||||
PyErr_SetFromErrno(mmap_module_error);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue