Changeset c1ed6527 for lib/ssl_gnutls.c


Ignore:
Timestamp:
2006-10-02T13:19:13Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
d9282b4
Parents:
88591fd
Message:

No more double free()/crashes when trying to set up an SSL connection to
a non-SSL server, and better handling of TLS connection setup by initializing
the TLS session from a callback function (which guarantees a valid return
value from ssl_starttls() before any error callback could be called).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/ssl_gnutls.c

    r88591fd rc1ed6527  
    4949
    5050static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond );
     51static gboolean ssl_starttls_real( gpointer data, gint source, b_input_condition cond );
     52static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond );
    5153
    5254
     
    6971}
    7072
    71 /* FIXME: It can happen that the handshake fails even before ssl_connected()
    72    returns already. This function will then return an invalid pointer because
    73    these failures can't be detected properly yet. Maybe ssl_connected()
    74    shouldn't be called directly, but via a short timeout? */
    7573void *ssl_starttls( int fd, ssl_input_function func, gpointer data )
    7674{
     
    8280        conn->inpa = -1;
    8381       
    84         ssl_connected( conn, fd, GAIM_INPUT_WRITE );
     82        /* This function should be called via a (short) timeout instead of
     83           directly from here, because these SSL calls are *supposed* to be
     84           *completely* asynchronous and not ready yet when this function
     85           (or *_connect, for examle) returns. Also, errors are reported via
     86           the callback function, not via this function's return value.
     87           
     88           In short, doing things like this makes the rest of the code a lot
     89           simpler. */
     90       
     91        b_timeout_add( 1, ssl_starttls_real, conn );
    8592       
    8693        return conn;
    8794}
    8895
    89 static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond );
     96static gboolean ssl_starttls_real( gpointer data, gint source, b_input_condition cond )
     97{
     98        struct scd *conn = data;
     99       
     100        return ssl_connected( conn, conn->fd, GAIM_INPUT_WRITE );
     101}
    90102
    91103static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond )
Note: See TracChangeset for help on using the changeset viewer.