forked from wolfSSL/wolfssl
Fix BioReceive
for closed connection
The pending check was forcing a `WOLFSSL_CBIO_ERR_WANT_WRITE` return even though the underlying socket was closed and `WOLFSSL_BIO_FLAG_READ|WOLFSSL_BIO_FLAG_RETRY` was not set. The `wolfSSL_BIO_ctrl_pending(ssl->biord) == 0` is old and I can't find a reason to keep checking it. I left it just in the case where there is output data pending.
This commit is contained in:
18
src/wolfio.c
18
src/wolfio.c
@ -169,15 +169,17 @@ int BioReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx)
|
||||
|
||||
recvd = wolfSSL_BIO_read(ssl->biord, buf, sz);
|
||||
if (recvd <= 0) {
|
||||
if (wolfSSL_BIO_supports_pending(ssl->biord) &&
|
||||
if (/* ssl->biowr->wrIdx is checked for Bind9 */
|
||||
ssl->biowr != NULL && ssl->biowr->type == WOLFSSL_BIO_BIO &&
|
||||
ssl->biowr->wrIdx != 0 &&
|
||||
/* Not sure this pending check is necessary but let's double
|
||||
* check that the read BIO is empty before we signal a write
|
||||
* need */
|
||||
wolfSSL_BIO_supports_pending(ssl->biord) &&
|
||||
wolfSSL_BIO_ctrl_pending(ssl->biord) == 0) {
|
||||
if (ssl->biowr->type == WOLFSSL_BIO_BIO &&
|
||||
ssl->biowr->wrIdx != 0) {
|
||||
/* Let's signal to the app layer that we have
|
||||
* data pending that needs to be sent. */
|
||||
return WOLFSSL_CBIO_ERR_WANT_WRITE;
|
||||
}
|
||||
return WOLFSSL_CBIO_ERR_WANT_READ;
|
||||
/* Let's signal to the app layer that we have
|
||||
* data pending that needs to be sent. */
|
||||
return WOLFSSL_CBIO_ERR_WANT_WRITE;
|
||||
}
|
||||
else if (ssl->biord->type == WOLFSSL_BIO_SOCKET) {
|
||||
if (recvd == 0) {
|
||||
|
Reference in New Issue
Block a user