]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #18135: Fix a possible integer overflow in ssl.SSLSocket.write()
authorVictor Stinner <victor.stinner@gmail.com>
Sun, 23 Jun 2013 13:15:10 +0000 (15:15 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Sun, 23 Jun 2013 13:15:10 +0000 (15:15 +0200)
for strings longer than 2 gigabytes.

Misc/NEWS
Modules/_ssl.c

index b4553668959590961a1e7103ce5186286d96691f..d7e15f3878023526cdad4af863ae79ad1220d462 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -21,6 +21,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #18135: Fix a possible integer overflow in ssl.SSLSocket.write()
+  for strings longer than 2 gigabytes.
+
 - Issue #18167: cgi.FieldStorage no more fails to handle multipart/form-data
   when \r\n appears at end of 65535 bytes without other newlines.
 
index 195e5b6491f8598ed34f3a07f7235332c02395c8..907429de160da3bf02ed7c789ec2fd575ceb1244 100644 (file)
@@ -1212,8 +1212,13 @@ static PyObject *PySSL_SSLwrite(PySSLObject *self, PyObject *args)
         goto error;
     }
     do {
+        if (buf.len <= INT_MAX)
+            len = (int)buf.len;
+        else
+            len = INT_MAX;
+
         PySSL_BEGIN_ALLOW_THREADS
-        len = SSL_write(self->ssl, buf.buf, buf.len);
+        len = SSL_write(self->ssl, buf.buf, len);
         err = SSL_get_error(self->ssl, len);
         PySSL_END_ALLOW_THREADS
         if (PyErr_CheckSignals()) {