Skip to content

Commit 6a8c3e7

Browse files
Account for negative read/write retval
1 parent 55553f3 commit 6a8c3e7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Modules/_ssl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,7 +2401,7 @@ _ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b)
24012401
do {
24022402
PySSL_BEGIN_ALLOW_THREADS
24032403
retval = SSL_write_ex(self->ssl, b->buf, (size_t)b->len, &count);
2404-
err = _PySSL_errno(retval == 0, self->ssl, count);
2404+
err = _PySSL_errno(retval <= 0, self->ssl, retval);
24052405
PySSL_END_ALLOW_THREADS
24062406
self->err = err;
24072407

@@ -2434,7 +2434,7 @@ _ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b)
24342434
err.ssl == SSL_ERROR_WANT_WRITE);
24352435

24362436
Py_XDECREF(sock);
2437-
if (retval == 0)
2437+
if (retval <= 0)
24382438
return PySSL_SetError(self, retval, __FILE__, __LINE__);
24392439
if (PySSL_ChainExceptions(self) < 0)
24402440
return NULL;
@@ -2553,7 +2553,7 @@ _ssl__SSLSocket_read_impl(PySSLSocket *self, Py_ssize_t len,
25532553
do {
25542554
PySSL_BEGIN_ALLOW_THREADS
25552555
retval = SSL_read_ex(self->ssl, mem, (size_t)len, &count);
2556-
err = _PySSL_errno(retval == 0, self->ssl, count);
2556+
err = _PySSL_errno(retval <= 0, self->ssl, retval);
25572557
PySSL_END_ALLOW_THREADS
25582558
self->err = err;
25592559

@@ -2586,7 +2586,7 @@ _ssl__SSLSocket_read_impl(PySSLSocket *self, Py_ssize_t len,
25862586
} while (err.ssl == SSL_ERROR_WANT_READ ||
25872587
err.ssl == SSL_ERROR_WANT_WRITE);
25882588

2589-
if (retval == 0) {
2589+
if (retval <= 0) {
25902590
PySSL_SetError(self, retval, __FILE__, __LINE__);
25912591
goto error;
25922592
}

0 commit comments

Comments
 (0)