From 3bd666cb4739939285645dd58afb10229d3f3337 Mon Sep 17 00:00:00 2001 From: bfis Date: Tue, 24 Aug 2021 12:43:19 +0200 Subject: [PATCH] Avoid 2GB write limitation on SSLIOStream --- tornado/iostream.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tornado/iostream.py b/tornado/iostream.py index 86235f4dc..e0ec51334 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -1566,6 +1566,11 @@ class SSLIOStream(IOStream): return future def write_to_fd(self, data: memoryview) -> int: + # clip buffer size at 1GB since SSL sockets only support upto 2GB + # this change in behaviour is transparent, since the function is + # already expected to (possibly) read less than the provided buffer + if len(data) >> 30: + data = memoryview(data)[: 1 << 30] try: return self.socket.send(data) # type: ignore except ssl.SSLError as e: -- 2.47.2