From: Andrew M. Kuchling Date: Tue, 15 Jul 2003 13:00:45 +0000 (+0000) Subject: [Patch #708374] Only apply the check for file size if the file is a regular file... X-Git-Tag: 2.2~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ed74a1019d98304b24c156a263a31865d1382724;p=thirdparty%2FPython%2Fcpython.git [Patch #708374] Only apply the check for file size if the file is a regular file, not a character or block device. --- diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index c72e4d5a2295..a73e0d8ffc7f 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;