Merge pull request #1957 from hardening/ssl_deco_fix

Fix unclean SSL disconnection
This commit is contained in:
Marc-André Moreau 2014-07-10 17:45:43 -04:00
commit 71c380830c
2 changed files with 20 additions and 15 deletions

View File

@ -122,23 +122,28 @@ static int transport_bio_simple_read(BIO* bio, char* buf, int size)
BIO_clear_flags(bio, BIO_FLAGS_READ);
status = _recv((SOCKET) bio->num, buf, size, 0);
if (status > 0)
return status;
if (status <= 0)
if (status == 0)
{
error = WSAGetLastError();
if ((error == WSAEWOULDBLOCK) || (error == WSAEINTR) ||
(error == WSAEINPROGRESS) || (error == WSAEALREADY))
{
BIO_set_flags(bio, (BIO_FLAGS_READ | BIO_FLAGS_SHOULD_RETRY));
}
else
{
BIO_clear_flags(bio, BIO_FLAGS_SHOULD_RETRY);
}
BIO_clear_flags(bio, BIO_FLAGS_SHOULD_RETRY);
return 0;
}
return status;
error = WSAGetLastError();
if ((error == WSAEWOULDBLOCK) || (error == WSAEINTR) ||
(error == WSAEINPROGRESS) || (error == WSAEALREADY))
{
BIO_set_flags(bio, (BIO_FLAGS_READ | BIO_FLAGS_SHOULD_RETRY));
}
else
{
BIO_clear_flags(bio, BIO_FLAGS_SHOULD_RETRY);
}
return -1;
}
static int transport_bio_simple_puts(BIO* bio, const char* str)
@ -327,7 +332,6 @@ static int transport_bio_buffered_read(BIO* bio, char* buf, int size)
if (!BIO_should_retry(bio->next_bio))
{
BIO_clear_flags(bio, BIO_FLAGS_SHOULD_RETRY);
status = -1;
goto out;
}

View File

@ -152,7 +152,8 @@ static int bio_rdp_tls_read(BIO* bio, char* buf, int size)
break;
case SSL_ERROR_SYSCALL:
status = 0;
BIO_clear_flags(bio, BIO_FLAGS_SHOULD_RETRY);
status = -1;
break;
}
}