(merge 3.2) Issue #9611, #9015: FileIO.read() clamps the length to INT_MAX on Windows.

This commit is contained in:
Victor Stinner 2011-07-05 11:34:18 +02:00
commit d9fc85db7f
2 changed files with 11 additions and 1 deletions

View file

@ -687,6 +687,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;
@ -695,7 +699,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;