-/* 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.
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
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);
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);
}