From d4dfad2aa9e76038302b0c5a29ebacc2723ed50d Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 16 Jan 2024 13:31:34 +0200 Subject: [PATCH] gh-114077: Fix OverflowError in socket.sendfile() when pass count >2GiB (GH-114079) --- Lib/socket.py | 2 +- .../next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst diff --git a/Lib/socket.py b/Lib/socket.py index 5f0a1f40e25..77986fc2e48 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -382,7 +382,7 @@ class socket(_socket.socket): if timeout and not selector_select(timeout): raise TimeoutError('timed out') if count: - blocksize = count - total_sent + blocksize = min(count - total_sent, blocksize) if blocksize <= 0: break try: diff --git a/Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst b/Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst new file mode 100644 index 00000000000..dba086f3a8a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst @@ -0,0 +1,2 @@ +Fix possible :exc:`OverflowError` in :meth:`socket.socket.sendfile` when pass +*count* larger than 2 GiB on 32-bit platform.