diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-06-24 21:13:24 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-06-24 21:13:24 (GMT) |
commit | 71765770a4a8cb0bc66b8b015e99606e23526957 (patch) | |
tree | 44594bd59febd271db13de25acbd61a13842cb9e /Modules/_winapi.c | |
parent | bc8ccce7298df728b2d81bd9c3bb9c8e236b882b (diff) | |
download | cpython-71765770a4a8cb0bc66b8b015e99606e23526957.zip cpython-71765770a4a8cb0bc66b8b015e99606e23526957.tar.gz cpython-71765770a4a8cb0bc66b8b015e99606e23526957.tar.bz2 |
Issue #9566: _winapi.WriteFile() now truncates length to DWORD_MAX (4294967295)
Diffstat (limited to 'Modules/_winapi.c')
-rw-r--r-- | Modules/_winapi.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Modules/_winapi.c b/Modules/_winapi.c index 1074891..c34d2db 100644 --- a/Modules/_winapi.c +++ b/Modules/_winapi.c @@ -62,6 +62,8 @@ #define T_HANDLE T_POINTER +#define DWORD_MAX 4294967295U + /* Grab CancelIoEx dynamically from kernel32 */ static int has_CancelIoEx = -1; static BOOL (CALLBACK *Py_CancelIoEx)(HANDLE, LPOVERLAPPED); @@ -1142,7 +1144,7 @@ winapi_WriteFile(PyObject *self, PyObject *args, PyObject *kwds) HANDLE handle; Py_buffer _buf, *buf; PyObject *bufobj; - DWORD written; + DWORD len, written; BOOL ret; int use_overlapped = 0; DWORD err; @@ -1170,7 +1172,8 @@ winapi_WriteFile(PyObject *self, PyObject *args, PyObject *kwds) } Py_BEGIN_ALLOW_THREADS - ret = WriteFile(handle, buf->buf, buf->len, &written, + len = (DWORD)Py_MIN(buf->len, DWORD_MAX); + ret = WriteFile(handle, buf->buf, len, &written, overlapped ? &overlapped->overlapped : NULL); Py_END_ALLOW_THREADS |