Skip to content

Commit 9eeb4b4

Browse files
authored
gh-82500: Fix asyncio sendfile overflow on 32bit (#107056)
1 parent 7fc9be3 commit 9eeb4b4

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

Lib/asyncio/unix_events.py

+3
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,9 @@ def _sock_sendfile_native_impl(self, fut, registered_fd, sock, fileno,
394394
fut.set_result(total_sent)
395395
return
396396

397+
# On 32-bit architectures truncate to 1GiB to avoid OverflowError
398+
blocksize = min(blocksize, sys.maxsize//2 + 1)
399+
397400
try:
398401
sent = os.sendfile(fd, fileno, offset, blocksize)
399402
except (BlockingIOError, InterruptedError):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix overflow on 32-bit systems with :mod:`asyncio` :func:`os.sendfile` implemention.

0 commit comments

Comments
 (0)