summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2003-07-15 13:00:45 +0000
committerAndrew M. Kuchling <amk@amk.ca>2003-07-15 13:00:45 +0000
commitddd6d2c452fb4ca808e1ed2e43e2746e530f494f (patch)
treeba87bfc2ccea4c652da152d8948b30feb2402743
parentfec9fb8c24f37a8a94618aaebde5473322f11217 (diff)
downloadcpython-ddd6d2c452fb4ca808e1ed2e43e2746e530f494f.tar.gz
[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 c72e4d5a22..a73e0d8ffc 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;