]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-114077: Fix OverflowError in socket.sendfile() when pass count >2GiB (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 16 Jan 2024 11:53:02 +0000 (12:53 +0100)
committerGitHub <noreply@github.com>
Tue, 16 Jan 2024 11:53:02 +0000 (13:53 +0200)
(cherry picked from commit d4dfad2aa9e76038302b0c5a29ebacc2723ed50d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/socket.py
Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst [new file with mode: 0644]

index 321fcda51505c18d36d5a51e6d51e4170fb25bc3..42ee130773264455a85dfd7608f96edfe13c43ff 100644 (file)
@@ -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 (file)
index 0000000..dba086f
--- /dev/null
@@ -0,0 +1,2 @@
+Fix possible :exc:`OverflowError` in :meth:`socket.socket.sendfile` when pass
+*count* larger than 2 GiB on 32-bit platform.