Update copyright year.
[umurmur.git] / src / ssl.c
index 2218864868e39daa3cdea1a04666e8ec863e91f9..6b7a5353f7aeb25674ccb093c82db9af800826cc 100644 (file)
--- a/src/ssl.c
+++ b/src/ssl.c
@@ -1,5 +1,5 @@
-/* Copyright (C) 2009-2012, Martin Johansson <martin@fatbob.nu>
-   Copyright (C) 2005-2012, Thorvald Natvig <thorvald@natvig.com>
+/* Copyright (C) 2009-2013, Martin Johansson <martin@fatbob.nu>
+   Copyright (C) 2005-2013, Thorvald Natvig <thorvald@natvig.com>
 
    All rights reserved.
 
@@ -154,13 +154,14 @@ 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)
                        continue;
                len -= cur;
        }
+       return 0;
 }
 #endif
 
@@ -275,7 +276,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 +325,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);
 }