diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-10-17 23:58:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-17 23:58:40 -0700 |
commit | 178d1c07778553bf66e09fe0bb13796be3fb9abf (patch) | |
tree | 30bb65bdf044cefc0dc90c46ebbf5ddc50876650 /Include | |
parent | 35ae99d7b394af0ce01460f7bccd7449a82289ad (diff) | |
download | cpython-git-178d1c07778553bf66e09fe0bb13796be3fb9abf.tar.gz |
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.
(cherry picked from commit 74a8b6ea7e0a8508b13a1c75ec9b91febd8b5557)
Co-authored-by: Stéphane Wirtel <stephane@wirtel.be>
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 e4bf6d4db9..c05ff43f51 100644 --- a/Include/fileutils.h +++ b/Include/fileutils.h @@ -60,6 +60,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; |