Skip to content

Commit 0e92265

Browse files
[3.11] gh-114077: Fix OverflowError in socket.sendfile() when pass count >2GiB (GH-114079) (GH-114111)
(cherry picked from commit d4dfad2) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent f5cbed1 commit 0e92265

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Lib/socket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def _sendfile_use_sendfile(self, file, offset=0, count=None):
381381
if timeout and not selector_select(timeout):
382382
raise TimeoutError('timed out')
383383
if count:
384-
blocksize = count - total_sent
384+
blocksize = min(count - total_sent, blocksize)
385385
if blocksize <= 0:
386386
break
387387
try:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix possible :exc:`OverflowError` in :meth:`socket.socket.sendfile` when pass
2+
*count* larger than 2 GiB on 32-bit platform.

0 commit comments

Comments
 (0)