]> granicus.if.org Git - python/commitdiff
[Patch #708374] Only apply the check for file size if the file is a regular file...
authorAndrew M. Kuchling <amk@amk.ca>
Tue, 15 Jul 2003 12:37:46 +0000 (12:37 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Tue, 15 Jul 2003 12:37:46 +0000 (12:37 +0000)
Modules/mmapmodule.c

index 56033e8d4e88c222d6c0d9f0a67e78c9f0615891..a61a37a10c664db3e9bbeed3dde5abcb8a20c4c2 100644 (file)
@@ -901,7 +901,8 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
        /* on OpenVMS we must ensure that all bytes are written to the file */
        fsync(fd);
 #  endif
-       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;