summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2003-07-15 13:00:45 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2003-07-15 13:00:45 (GMT)
commited74a1019d98304b24c156a263a31865d1382724 (patch)
treefb7b55f65eb3e1b48b72fa1ec7a4e3207d172f23
parent34166684998ad922768127da19402e86f56d5c32 (diff)
downloadcpython-ed74a1019d98304b24c156a263a31865d1382724.zip
cpython-ed74a1019d98304b24c156a263a31865d1382724.tar.gz
cpython-ed74a1019d98304b24c156a263a31865d1382724.tar.bz2
[Patch #708374] Only apply the check for file size if the file is a regular file, not a character or block device.
-rw-r--r--Modules/mmapmodule.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index c72e4d5..a73e0d8 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -897,7 +897,8 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
}
#ifdef HAVE_FSTAT
- if (fstat(fd, &st) == 0 && (size_t)map_size > st.st_size) {
+ if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode) &&
+ (size_t)map_size > st.st_size) {
PyErr_SetString(PyExc_ValueError,
"mmap length is greater than file size");
return NULL;