summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-06-23 13:15:10 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-06-23 13:15:10 (GMT)
commit4807df41ad7871f5fcf0e4568c71f8e101eb5738 (patch)
treeb3d8a59cfc86821644785bed966f7671ee50e43e /Modules
parent760388100e2cc21c5d58a9014db5426e6107b5e4 (diff)
downloadcpython-4807df41ad7871f5fcf0e4568c71f8e101eb5738.zip
cpython-4807df41ad7871f5fcf0e4568c71f8e101eb5738.tar.gz
cpython-4807df41ad7871f5fcf0e4568c71f8e101eb5738.tar.bz2
Issue #18135: Fix a possible integer overflow in ssl.SSLSocket.write()
for strings longer than 2 gigabytes.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ssl.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 195e5b6..907429d 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -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()) {