From: Martin Johansson Date: Tue, 14 May 2013 20:36:13 +0000 (+0200) Subject: Fix crash at client disconnect when using PolarSSL >= 1.2.6 X-Git-Url: http://git.code-monkey.de/?p=umurmur.git;a=commitdiff_plain;h=5a87eb073e217f56a5365f0ee862d38ea6f79b84 Fix crash at client disconnect when using PolarSSL >= 1.2.6 --- diff --git a/src/ssl.c b/src/ssl.c index 2218864..86e35a5 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -154,7 +154,7 @@ static void initKey() int urandom_bytes(void *ctx, unsigned char *dest, size_t len) { int cur; - + while (len) { cur = read(urandom_fd, dest, len); if (cur < 0) @@ -275,7 +275,7 @@ int SSLi_nonblockaccept(SSL_handle_t *ssl, bool_t *SSLready) if (rc != 0) { if (rc == POLARSSL_ERR_NET_WANT_READ || rc == POLARSSL_ERR_NET_WANT_WRITE) { return 0; - } else if (POLARSSL_ERR_X509_CERT_VERIFY_FAILED) { /* Allow this (selfsigned etc) */ + } else if (rc == POLARSSL_ERR_X509_CERT_VERIFY_FAILED) { /* Allow this (selfsigned etc) */ return 0; } else { Log_warn("SSL handshake failed: %d", rc); @@ -324,7 +324,10 @@ void SSLi_shutdown(SSL_handle_t *ssl) void SSLi_free(SSL_handle_t *ssl) { Log_debug("SSLi_free"); - free(ssl->session); /* XXX - Hmmm. */ +#if (POLARSSL_VERSION_MINOR <= 2 && POLARSSL_VERSION_PATCH < 6) + free(ssl->session); /* Workaround for memory leak in PolarSSL < 1.2.6 */ + ssl->session = NULL; +#endif ssl_free(ssl); free(ssl); }