[Patch #708374] Only apply the check for file size if the file is a regular file, not a character or block device.

This commit is contained in:
Andrew M. Kuchling 2003-07-15 12:37:46 +00:00
parent c171172614
commit a3016678ed
1 changed files with 2 additions and 1 deletions

View 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 */ /* on OpenVMS we must ensure that all bytes are written to the file */
fsync(fd); fsync(fd);
# endif # 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, PyErr_SetString(PyExc_ValueError,
"mmap length is greater than file size"); "mmap length is greater than file size");
return NULL; return NULL;