diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-01-15 16:17:07 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-01-15 16:17:07 (GMT) |
commit | 85f461550057e2a797cf7015c31f1a6d63553493 (patch) | |
tree | b22a2158061dcbcb396d39f2ea4abb7f0633835a /Modules | |
parent | f5cf435bb52c8ba5ab6813bde70696fa3de98efa (diff) | |
download | cpython-85f461550057e2a797cf7015c31f1a6d63553493.zip cpython-85f461550057e2a797cf7015c31f1a6d63553493.tar.gz cpython-85f461550057e2a797cf7015c31f1a6d63553493.tar.bz2 |
Issue #10916: mmap should not segfault when a file is mapped using 0 as
length and a non-zero offset, and an attempt to read past the end of file
is made (IndexError is raised instead). Patch by Ross Lagerwall.
Requested by Georg.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/mmapmodule.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 8a22752..ef026b2 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -1116,7 +1116,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict) # endif if (fd != -1 && fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) { if (map_size == 0) { - map_size = st.st_size; + map_size = st.st_size - offset; } else if ((size_t)offset + (size_t)map_size > st.st_size) { PyErr_SetString(PyExc_ValueError, "mmap length is greater than file size"); |