]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Avoid 2GB write limitation on SSLIOStream
authorbfis <b.fis@cern.ch>
Tue, 24 Aug 2021 10:43:19 +0000 (12:43 +0200)
committerGitHub <noreply@github.com>
Tue, 24 Aug 2021 10:43:19 +0000 (12:43 +0200)
tornado/iostream.py

index 86235f4dc34f6651e0351b8d7a1015164e9d0cd3..e0ec51334feeb07a4bac630dfb7169f8921ee7c3 100644 (file)
@@ -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: