aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Modules/binascii.c
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-02-07 09:25:06 +0300
committerAlexander Smirnov <alex@ydb.tech>2024-02-09 19:18:32 +0300
commitf0785dc88eee3da0f1514f5b4cafa931571e669d (patch)
tree44165310ad6023cd29776f9b1b4477364cd2b5bb /contrib/tools/python3/src/Modules/binascii.c
parent2c0985fb513cb5b352324abf223bf749c6c2bd24 (diff)
downloadydb-f0785dc88eee3da0f1514f5b4cafa931571e669d.tar.gz
Update Python 3 to 3.11.8
Diffstat (limited to 'contrib/tools/python3/src/Modules/binascii.c')
-rw-r--r--contrib/tools/python3/src/Modules/binascii.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/contrib/tools/python3/src/Modules/binascii.c b/contrib/tools/python3/src/Modules/binascii.c
index afe4988549..de3c2d8895 100644
--- a/contrib/tools/python3/src/Modules/binascii.c
+++ b/contrib/tools/python3/src/Modules/binascii.c
@@ -780,12 +780,20 @@ binascii_crc32_impl(PyObject *module, Py_buffer *data, unsigned int crc)
Py_BEGIN_ALLOW_THREADS
/* Avoid truncation of length for very large buffers. crc32() takes
- length as an unsigned int, which may be narrower than Py_ssize_t. */
- while ((size_t)len > UINT_MAX) {
- crc = crc32(crc, buf, UINT_MAX);
- buf += (size_t) UINT_MAX;
- len -= (size_t) UINT_MAX;
+ length as an unsigned int, which may be narrower than Py_ssize_t.
+ We further limit size due to bugs in Apple's macOS zlib.
+ See https://github.com/python/cpython/issues/105967
+ */
+#define ZLIB_CRC_CHUNK_SIZE 0x40000000
+#if ZLIB_CRC_CHUNK_SIZE > INT_MAX
+# error "unsupported less than 32-bit platform?"
+#endif
+ while ((size_t)len > ZLIB_CRC_CHUNK_SIZE) {
+ crc = crc32(crc, buf, ZLIB_CRC_CHUNK_SIZE);
+ buf += (size_t) ZLIB_CRC_CHUNK_SIZE;
+ len -= (size_t) ZLIB_CRC_CHUNK_SIZE;
}
+#undef ZLIB_CRC_CHUNK_SIZE
crc = crc32(crc, buf, (unsigned int)len);
Py_END_ALLOW_THREADS
} else {