Changeset 2fb1262 for lib


Ignore:
Timestamp:
2012-11-11T18:22:39Z (12 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
dd672e2
Parents:
1388d30
Message:

Tiny cleanup. Fixing some memory leaks (why did I not notice so far that
those free()s were commented out?).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/ssl_gnutls.c

    r1388d30 r2fb1262  
    3838
    3939static gboolean initialized = FALSE;
    40 gnutls_certificate_credentials xcred;
     40gnutls_certificate_credentials_t xcred;
    4141
    4242#include <limits.h>
     
    6060        gboolean verify;
    6161       
    62         gnutls_session session;
     62        gnutls_session_t session;
    6363};
    6464
     
    132132        conn->data = data;
    133133        conn->inpa = -1;
    134         conn->hostname = hostname;
     134        conn->hostname = g_strdup( hostname );
    135135       
    136136        /* For now, SSL verification is globally enabled by setting the cafile
     
    169169        int verifyret = 0;
    170170        gnutls_x509_crt_t cert;
    171         const char *hostname;
    172        
    173         hostname = gnutls_session_get_ptr( session );
     171        struct scd *conn;
     172       
     173        conn = gnutls_session_get_ptr( session );
    174174
    175175        gnutlsret = gnutls_certificate_verify_peers2( session, &status );
     
    209209                return VERIFY_CERT_ERROR;
    210210
    211         if( !gnutls_x509_crt_check_hostname( cert, hostname ) )
     211        if( !gnutls_x509_crt_check_hostname( cert, conn->hostname ) )
    212212        {
    213213                verifyret |= VERIFY_CERT_INVALID;
     
    265265       
    266266        gnutls_init( &conn->session, GNUTLS_CLIENT );
    267         if( conn->verify )
    268                 gnutls_session_set_ptr( conn->session, (void *) conn->hostname );
     267        gnutls_session_set_ptr( conn->session, (void *) conn );
    269268#if GNUTLS_VERSION_NUMBER < 0x020c00
    270269        gnutls_transport_set_lowat( conn->session, 0 );
     
    274273       
    275274        sock_make_nonblocking( conn->fd );
    276         gnutls_transport_set_ptr( conn->session, (gnutls_transport_ptr) GNUTLS_STUPID_CAST conn->fd );
     275        gnutls_transport_set_ptr( conn->session, (gnutls_transport_ptr_t) GNUTLS_STUPID_CAST conn->fd );
    277276       
    278277        return ssl_handshake( data, source, cond );
     
    400399        if( conn->session )
    401400                gnutls_deinit( conn->session );
     401        g_free( conn->hostname );
    402402        g_free( conn );
    403403}
Note: See TracChangeset for help on using the changeset viewer.