Merge pull request #73 from perry-clarke/master

Fix crash after dohandshake() fails (need some adjusts yet)
This commit is contained in:
Bruno Silvestre 2016-08-03 14:53:53 -03:00 committed by GitHub
commit 9efa963e35

View File

@ -191,19 +191,19 @@ static int ssl_recv(void *ctx, char *data, size_t count, size_t *got,
{ {
int err; int err;
p_ssl ssl = (p_ssl)ctx; p_ssl ssl = (p_ssl)ctx;
*got = 0;
if (ssl->state != LSEC_STATE_CONNECTED) if (ssl->state != LSEC_STATE_CONNECTED)
return IO_CLOSED; return IO_CLOSED;
*got = 0;
for ( ; ; ) { for ( ; ; ) {
ERR_clear_error(); ERR_clear_error();
err = SSL_read(ssl->ssl, data, (int)count); err = SSL_read(ssl->ssl, data, (int)count);
ssl->error = SSL_get_error(ssl->ssl, err); ssl->error = SSL_get_error(ssl->ssl, err);
switch (ssl->error) { switch (ssl->error) {
case SSL_ERROR_NONE: case SSL_ERROR_NONE:
*got = err; *got = 0;
return IO_DONE; return IO_DONE;
case SSL_ERROR_ZERO_RETURN: case SSL_ERROR_ZERO_RETURN:
*got = err; *got = 0;
return IO_CLOSED; return IO_CLOSED;
case SSL_ERROR_WANT_READ: case SSL_ERROR_WANT_READ:
err = socket_waitfd(&ssl->sock, WAITFD_R, tm); err = socket_waitfd(&ssl->sock, WAITFD_R, tm);