summaryrefslogtreecommitdiffstats
path: root/Modules/mmapmodule.c
diff options
context:
space:
mode:
authorJesus Cea <jcea@jcea.es>2012-09-10 20:50:21 (GMT)
committerJesus Cea <jcea@jcea.es>2012-09-10 20:50:21 (GMT)
commit4886d5b3385800cb302336b1ec3153833345226e (patch)
treebfa0fc5e526e007751f68c560d8adb8f7e2bd3f5 /Modules/mmapmodule.c
parent7b9c48f3398468b28d6659844e0e9c0c8e9771fa (diff)
parent1f2799bef45673419e96ad4ef6a923c59d1c6a85 (diff)
downloadcpython-4886d5b3385800cb302336b1ec3153833345226e.zip
cpython-4886d5b3385800cb302336b1ec3153833345226e.tar.gz
cpython-4886d5b3385800cb302336b1ec3153833345226e.tar.bz2
#15676: mmap: add empty file check prior to offset check <- Previous patch was incomplete
Diffstat (limited to 'Modules/mmapmodule.c')
-rw-r--r--Modules/mmapmodule.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index 0f22d49..3e20934 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -1364,6 +1364,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");