https://github.com/python/cpython/commit/0e922658755a6e62995661f03aca86cda13ba03e
commit: 0e922658755a6e62995661f03aca86cda13ba03e
branch: 3.11
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: serhiy-storchaka <storch...@gmail.com>
date: 2024-01-16T13:53:26+02:00
summary:

[3.11] gh-114077: Fix OverflowError in socket.sendfile() when pass count >2GiB 
(GH-114079) (GH-114111)

(cherry picked from commit d4dfad2aa9e76038302b0c5a29ebacc2723ed50d)

Co-authored-by: Serhiy Storchaka <storch...@gmail.com>

files:
A Misc/NEWS.d/next/Library/2024-01-15-12-12-54.gh-issue-114077.KcVnfj.rst
M Lib/socket.py

diff --git a/Lib/socket.py b/Lib/socket.py
index b5d46eb32bda3b..a0567b76bcfe2b 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -381,7 +381,7 @@ def _sendfile_use_sendfile(self, file, offset=0, 
count=None):
                     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 00000000000000..dba086f3a8a484
--- /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.

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to