Skip to content

Commit 045adb1

Browse files
[3.12] gh-114077: Fix OverflowError in socket.sendfile() when pass count >2GiB (GH-114079) (GH-114110)
(cherry picked from commit d4dfad2) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent 2b02579 commit 045adb1

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
@@ -382,7 +382,7 @@ def _sendfile_use_sendfile(self, file, offset=0, count=None):
382382
if timeout and not selector_select(timeout):
383383
raise TimeoutError('timed out')
384384
if count:
385-
blocksize = count - total_sent
385+
blocksize = min(count - total_sent, blocksize)
386386
if blocksize <= 0:
387387
break
388388
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)