summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorJesus Cea <jcea@jcea.es>2012-09-10 20:49:50 (GMT)
committerJesus Cea <jcea@jcea.es>2012-09-10 20:49:50 (GMT)
commit1f2799bef45673419e96ad4ef6a923c59d1c6a85 (patch)
treef69d47f2609cb35b8e38c6e0e557ac432ced6c0f /Modules
parent3159cb51a77da430272bfaf42c768493c72b456a (diff)
downloadcpython-1f2799bef45673419e96ad4ef6a923c59d1c6a85.zip
cpython-1f2799bef45673419e96ad4ef6a923c59d1c6a85.tar.gz
cpython-1f2799bef45673419e96ad4ef6a923c59d1c6a85.tar.bz2
#15676: mmap: add empty file check prior to offset check <- Previous patch was incomplete
Diffstat (limited to 'Modules')
-rw-r--r--Modules/mmapmodule.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index e23613e..b993fdf 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -1342,6 +1342,11 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
}
size = (((PY_LONG_LONG) high) << 32) + low;
+ if (size == 0) {
+ PyErr_SetString(PyExc_ValueError,
+ "cannot mmap an empty file");
+ return NULL;
+ }
if (offset >= size) {
PyErr_SetString(PyExc_ValueError,
"mmap offset is greater than file size");