diff -r f0d934732ab1 Modules/_ssl.c --- a/Modules/_ssl.c Sun Jun 23 15:08:23 2013 +0200 +++ b/Modules/_ssl.c Sun Jun 23 15:55:33 2013 +0200 @@ -1264,6 +1264,12 @@ static PyObject *PySSL_SSLwrite(PySSLSoc return NULL; } + if (buf.len > INT_MAX) { + PyErr_Format(PyExc_OverflowError, + "string longer than %d bytes", INT_MAX); + goto error; + } + /* just in case the blocking state of the socket has been changed */ nonblocking = (sock->sock_timeout >= 0.0); BIO_set_nbio(SSL_get_rbio(self->ssl), nonblocking); @@ -1284,7 +1290,6 @@ static PyObject *PySSL_SSLwrite(PySSLSoc goto error; } do { - len = (int)Py_MIN(buf.len, INT_MAX); PySSL_BEGIN_ALLOW_THREADS len = SSL_write(self->ssl, buf.buf, len); err = SSL_get_error(self->ssl, len);