Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.10] bpo-42854: Correctly use size_t for _ssl._SSLSocket.read and _ssl._SSLSocket.write (GH-27271) #27308

Merged
merged 1 commit into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fixed a bug in the :mod:`_ssl` module that was throwing :exc:`OverflowError`
when using :meth:`_ssl._SSLSocket.write` and :meth:`_ssl._SSLSocket.read`
for a big value of the ``len`` parameter. Patch by Pablo Galindo
12 changes: 6 additions & 6 deletions Modules/_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2346,7 +2346,7 @@ _ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b)

do {
PySSL_BEGIN_ALLOW_THREADS
retval = SSL_write_ex(self->ssl, b->buf, (int)b->len, &count);
retval = SSL_write_ex(self->ssl, b->buf, (size_t)b->len, &count);
err = _PySSL_errno(retval == 0, self->ssl, retval);
PySSL_END_ALLOW_THREADS
self->err = err;
Expand Down Expand Up @@ -2418,7 +2418,7 @@ _ssl__SSLSocket_pending_impl(PySSLSocket *self)

/*[clinic input]
_ssl._SSLSocket.read
size as len: int
size as len: Py_ssize_t
[
buffer: Py_buffer(accept={rwbuffer})
]
Expand All @@ -2428,9 +2428,9 @@ Read up to size bytes from the SSL socket.
[clinic start generated code]*/

static PyObject *
_ssl__SSLSocket_read_impl(PySSLSocket *self, int len, int group_right_1,
Py_buffer *buffer)
/*[clinic end generated code: output=00097776cec2a0af input=ff157eb918d0905b]*/
_ssl__SSLSocket_read_impl(PySSLSocket *self, Py_ssize_t len,
int group_right_1, Py_buffer *buffer)
/*[clinic end generated code: output=49b16e6406023734 input=ec48bf622be1c4a1]*/
{
PyObject *dest = NULL;
char *mem;
Expand Down Expand Up @@ -2498,7 +2498,7 @@ _ssl__SSLSocket_read_impl(PySSLSocket *self, int len, int group_right_1,

do {
PySSL_BEGIN_ALLOW_THREADS
retval = SSL_read_ex(self->ssl, mem, len, &count);
retval = SSL_read_ex(self->ssl, mem, (size_t)len, &count);
err = _PySSL_errno(retval == 0, self->ssl, retval);
PySSL_END_ALLOW_THREADS
self->err = err;
Expand Down
12 changes: 6 additions & 6 deletions Modules/clinic/_ssl.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.