Make tls_new_client_session() take talloc_ctx
authorAlan T. DeKok <aland@freeradius.org>
Wed, 4 Mar 2015 14:47:06 +0000 (09:47 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 4 Mar 2015 14:47:06 +0000 (09:47 -0500)
and pass in correct ctx so we don't leak memory

src/include/tls-h
src/main/listen.c
src/main/tls.c

index ccf3feb..a25c19c 100644 (file)
@@ -300,7 +300,7 @@ int         tls_global_version_check(char const *acknowledged);
 #endif
 void           tls_global_cleanup(void);
 tls_session_t  *tls_new_session(TALLOC_CTX *ctx, fr_tls_server_conf_t *conf, REQUEST *request, bool client_cert);
-tls_session_t  *tls_new_client_session(fr_tls_server_conf_t *conf, int fd);
+tls_session_t  *tls_new_client_session(TALLOC_CTX *ctx, fr_tls_server_conf_t *conf, int fd);
 fr_tls_server_conf_t *tls_server_conf_parse(CONF_SECTION *cs);
 fr_tls_server_conf_t *tls_client_conf_parse(CONF_SECTION *cs);
 SSL_CTX                *tls_init_ctx(fr_tls_server_conf_t *conf, int client);
index 6c04f4b..a4d1124 100644 (file)
@@ -2733,7 +2733,7 @@ rad_listen_t *proxy_new_listener(home_server_t *home, uint16_t src_port)
 #ifdef WITH_TLS
        if ((home->proto == IPPROTO_TCP) && home->tls) {
                DEBUG("Trying SSL to port %d\n", home->port);
-               sock->ssn = tls_new_client_session(home->tls, this->fd);
+               sock->ssn = tls_new_client_session(sock, home->tls, this->fd);
                if (!sock->ssn) {
                        ERROR("Failed starting SSL to '%s'", buffer);
                        home->last_failed_open = now;
index 3dd7f10..04280c9 100644 (file)
@@ -210,13 +210,13 @@ static unsigned int psk_client_callback(SSL *ssl, UNUSED char const *hint,
 
 #endif
 
-tls_session_t *tls_new_client_session(fr_tls_server_conf_t *conf, int fd)
+tls_session_t *tls_new_client_session(TALLOC_CTX *ctx, fr_tls_server_conf_t *conf, int fd)
 {
        int verify_mode;
        tls_session_t *ssn = NULL;
        REQUEST *request;
 
-       ssn = talloc_zero(conf, tls_session_t);
+       ssn = talloc_zero(ctx, tls_session_t);
        if (!ssn) return NULL;
 
        ssn->ctx = conf->ctx;