gh-82500: Fix asyncio sendfile overflow on 32bit (#107056)

This commit is contained in:
J. Nick Koston 2023-07-22 23:07:14 -05:00 committed by GitHub
parent 7fc9be350a
commit 9eeb4b485f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -394,6 +394,9 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
fut.set_result(total_sent)
return
# On 32-bit architectures truncate to 1GiB to avoid OverflowError
blocksize = min(blocksize, sys.maxsize//2 + 1)
try:
sent = os.sendfile(fd, fileno, offset, blocksize)
except (BlockingIOError, InterruptedError):

View File

@ -0,0 +1 @@
Fix overflow on 32-bit systems with :mod:`asyncio` :func:`os.sendfile` implemention.