diff options
author | Stéphane Wirtel <stephane@wirtel.be> | 2018-10-17 23:05:04 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2018-10-17 23:05:04 (GMT) |
commit | 74a8b6ea7e0a8508b13a1c75ec9b91febd8b5557 (patch) | |
tree | 2ae2721beb480ede309e03b90202038b63c5a22c /Include | |
parent | 0f11a88622ceda93a6b7eed7db52a5eb8083445f (diff) | |
download | cpython-74a8b6ea7e0a8508b13a1c75ec9b91febd8b5557.zip cpython-74a8b6ea7e0a8508b13a1c75ec9b91febd8b5557.tar.gz cpython-74a8b6ea7e0a8508b13a1c75ec9b91febd8b5557.tar.bz2 |
bpo-24658: Fix read/write greater than 2 GiB on macOS (GH-1705)
On macOS, fix reading from and writing into a file with a size larger than 2 GiB.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/fileutils.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Include/fileutils.h b/Include/fileutils.h index f0a8e2c..232d966 100644 --- a/Include/fileutils.h +++ b/Include/fileutils.h @@ -81,6 +81,19 @@ PyAPI_FUNC(int) _Py_EncodeLocaleEx( #ifndef Py_LIMITED_API PyAPI_FUNC(PyObject *) _Py_device_encoding(int); +#if defined(MS_WINDOWS) || defined(__APPLE__) + /* On Windows, the count parameter of read() is an int (bpo-9015, bpo-9611). + On macOS 10.13, read() and write() with more than INT_MAX bytes + fail with EINVAL (bpo-24658). */ +# define _PY_READ_MAX INT_MAX +# define _PY_WRITE_MAX INT_MAX +#else + /* write() should truncate the input to PY_SSIZE_T_MAX bytes, + but it's safer to do it ourself to have a portable behaviour */ +# define _PY_READ_MAX PY_SSIZE_T_MAX +# define _PY_WRITE_MAX PY_SSIZE_T_MAX +#endif + #ifdef MS_WINDOWS struct _Py_stat_struct { unsigned long st_dev; |