summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-07-05 09:31:49 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-07-05 09:31:49 (GMT)
commitc655a726dba5799e3c221b6c95fee72516d3d7cf (patch)
tree42520ad3158db726a4ffc53c59a34e9bbfa7affe /Modules
parentbb4a747b695a3c1cce5257f40bc764fb9b44476a (diff)
downloadcpython-c655a726dba5799e3c221b6c95fee72516d3d7cf.zip
cpython-c655a726dba5799e3c221b6c95fee72516d3d7cf.tar.gz
cpython-c655a726dba5799e3c221b6c95fee72516d3d7cf.tar.bz2
Issue #9611, #9015: FileIO.read() clamps the length to INT_MAX on Windows.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_io/fileio.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index 141b6de..b1d492b 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -664,6 +664,10 @@ fileio_read(fileio *self, PyObject *args)
return fileio_readall(self);
}
+#if defined(MS_WIN64) || defined(MS_WINDOWS)
+ if (size > INT_MAX)
+ size = INT_MAX;
+#endif
bytes = PyBytes_FromStringAndSize(NULL, size);
if (bytes == NULL)
return NULL;
@@ -672,7 +676,11 @@ fileio_read(fileio *self, PyObject *args)
if (_PyVerify_fd(self->fd)) {
Py_BEGIN_ALLOW_THREADS
errno = 0;
+#if defined(MS_WIN64) || defined(MS_WINDOWS)
+ n = read(self->fd, ptr, (int)size);
+#else
n = read(self->fd, ptr, size);
+#endif
Py_END_ALLOW_THREADS
} else
n = -1;