summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-01-04 00:29:35 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-01-04 00:29:35 (GMT)
commite6edec23718072ed7903be9dae37ae330a9d81d5 (patch)
treedd43a4d1de61a8b0b49bef7f3fb299638f7aded9 /Modules/posixmodule.c
parent560f9dab55701654706b0d257d5d8f34f633bb52 (diff)
downloadcpython-e6edec23718072ed7903be9dae37ae330a9d81d5.zip
cpython-e6edec23718072ed7903be9dae37ae330a9d81d5.tar.gz
cpython-e6edec23718072ed7903be9dae37ae330a9d81d5.tar.bz2
Issue #9015, #9611: FileIO.readinto(), FileIO.write() and os.write() clamp the
length to 2^31-1 on Windows.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index d7891fa..0cd6340 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -5696,7 +5696,7 @@ posix_write(PyObject *self, PyObject *args)
{
Py_buffer pbuf;
int fd;
- Py_ssize_t size;
+ Py_ssize_t size, len;
if (!PyArg_ParseTuple(args, "iy*:write", &fd, &pbuf))
return NULL;
@@ -5704,8 +5704,15 @@ posix_write(PyObject *self, PyObject *args)
PyBuffer_Release(&pbuf);
return posix_error();
}
+ len = pbuf.len;
Py_BEGIN_ALLOW_THREADS
- size = write(fd, pbuf.buf, (size_t)pbuf.len);
+#if defined(MS_WIN64) || defined(MS_WINDOWS)
+ if (len > INT_MAX)
+ len = INT_MAX;
+ size = write(fd, pbuf.buf, (int)len);
+#else
+ size = write(fd, pbuf.buf, (size_t)len);
+#endif
Py_END_ALLOW_THREADS
PyBuffer_Release(&pbuf);
if (size < 0)