diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-06-24 22:43:47 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-06-24 22:43:47 (GMT) |
commit | 86073dc3c2aaa5c9292bd63ccc1db4da10f712c9 (patch) | |
tree | 0d093914ebcc0e774588388c0dad4196135cd16a /Modules/_ssl.c | |
parent | 14b9b110982fd7f00392b898230c4015bd2bdaaa (diff) | |
parent | 6efa965a27696ae0acf1c914ca71b545a53be01c (diff) | |
download | cpython-86073dc3c2aaa5c9292bd63ccc1db4da10f712c9.zip cpython-86073dc3c2aaa5c9292bd63ccc1db4da10f712c9.tar.gz cpython-86073dc3c2aaa5c9292bd63ccc1db4da10f712c9.tar.bz2 |
(Merge 3.3) Issue #18135: ssl.SSLSocket.write() now raises an OverflowError if
the input string in longer than 2 gigabytes, and
ssl.SSLContext.load_cert_chain() raises a ValueError if the password is longer
than 2 gigabytes. The ssl module does not support partial write.
Diffstat (limited to 'Modules/_ssl.c')
-rw-r--r-- | Modules/_ssl.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c index dce84c0..4208cb0 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -1338,6 +1338,12 @@ static PyObject *PySSL_SSLwrite(PySSLSocket *self, PyObject *args) 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); @@ -1358,9 +1364,8 @@ static PyObject *PySSL_SSLwrite(PySSLSocket *self, PyObject *args) goto error; } do { - len = (int)Py_MIN(buf.len, INT_MAX); PySSL_BEGIN_ALLOW_THREADS - len = SSL_write(self->ssl, buf.buf, len); + len = SSL_write(self->ssl, buf.buf, (int)buf.len); err = SSL_get_error(self->ssl, len); PySSL_END_ALLOW_THREADS if (PyErr_CheckSignals()) { |