From f6ce8c9abb880bc1fe605e5b2dce5bae3df66a8e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 29 Oct 2015 22:57:09 +0100 Subject: mbedtls: fix "Logically dead code" CID 1332128 --- lib/vtls/mbedtls.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'lib/vtls/mbedtls.c') diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c index b2627e4e9..fa445afd5 100644 --- a/lib/vtls/mbedtls.c +++ b/lib/vtls/mbedtls.c @@ -415,30 +415,25 @@ mbedtls_connect_step2(struct connectdata *conn, conn->send[sockindex] = mbedtls_send; for(;;) { - if(!(ret = mbedtls_ssl_handshake(&connssl->ssl))) + ret = mbedtls_ssl_handshake(&connssl->ssl); + if(!ret) break; + if(ret == MBEDTLS_ERR_SSL_WANT_READ) { + connssl->connecting_state = ssl_connect_2_reading; + return CURLE_OK; + } + else if(ret == MBEDTLS_ERR_SSL_WANT_WRITE) { + connssl->connecting_state = ssl_connect_2_writing; + return CURLE_OK; + } else if(ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) { #ifdef MBEDTLS_ERROR_C - mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); + mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); #endif /* MBEDTLS_ERROR_C */ - failf(data, "ssl_handshake returned - mbedTLS: (-0x%04X) %s", - -ret, errorbuf); - - return CURLE_SSL_CONNECT_ERROR; - } - else { - if(ret == MBEDTLS_ERR_SSL_WANT_READ) { - connssl->connecting_state = ssl_connect_2_reading; - return CURLE_OK; - } - if(ret == MBEDTLS_ERR_SSL_WANT_WRITE) { - connssl->connecting_state = ssl_connect_2_writing; - return CURLE_OK; - } - failf(data, "SSL_connect failed with error %d.", ret); + failf(data, "ssl_handshake returned - mbedTLS: (-0x%04X) %s", + -ret, errorbuf); return CURLE_SSL_CONNECT_ERROR; - } } -- cgit v1.2.3