diff options
author | Brian Curtin <brian.curtin@gmail.com> | 2010-08-01 15:26:26 (GMT) |
---|---|---|
committer | Brian Curtin <brian.curtin@gmail.com> | 2010-08-01 15:26:26 (GMT) |
commit | ea47eaa3955db096bbf3e0204cce8e342d74a8ae (patch) | |
tree | 9a2e4afed436803f86f65f8c611b4ef09d403c73 /Modules/mmapmodule.c | |
parent | 0bccc185b4d333a6c50c18c8d1d9916aca96a99c (diff) | |
download | cpython-ea47eaa3955db096bbf3e0204cce8e342d74a8ae.zip cpython-ea47eaa3955db096bbf3e0204cce8e342d74a8ae.tar.gz cpython-ea47eaa3955db096bbf3e0204cce8e342d74a8ae.tar.bz2 |
Fix #8105. Add validation to mmap.mmap so invalid file descriptors
don't cause a crash on Windows.
Diffstat (limited to 'Modules/mmapmodule.c')
-rw-r--r-- | Modules/mmapmodule.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index de527ce..3973124 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -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); |