mirror of
https://github.com/python/cpython.git
synced 2025-09-20 15:40:32 +00:00
Closes #15676: mmap: add empty file check prior to offset check
This commit is contained in:
parent
10fc104fed
commit
8b54d6d733
3 changed files with 24 additions and 0 deletions
|
@ -1189,6 +1189,11 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
|
|||
if (fd != -1 && fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) {
|
||||
if (map_size == 0) {
|
||||
off_t calc_size;
|
||||
if (st.st_size == 0) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"cannot mmap an empty file");
|
||||
return NULL;
|
||||
}
|
||||
if (offset >= st.st_size) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"mmap offset is greater than file size");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue