Mercurial > pidgin
diff libpurple/plugins/ssl/ssl-gnutls.c @ 29659:df9de37e0274
gnutls/nss: Don't call the handshake functions synchronously. Fixes #11525
If the handshake callbacks are called sychronously and they fail
(e.g. passing GnuTLS a bad priority string or doing voodoo with NSS, see
#11524 for details), the error_cb is called and the gsc destroyed, but this
happens /before/ the assignment to, e.g., js->gsc happens (see
jabber.c:tls_init). Thus, js->gsc is assigned a (now invalid) pointer
and jabber_close tries to free it (again).
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Thu, 01 Apr 2010 05:26:44 +0000 |
parents | 1b8ed243d6d1 |
children | 43af903bd816 |
line wrap: on
line diff
--- a/libpurple/plugins/ssl/ssl-gnutls.c Thu Apr 01 04:58:17 2010 +0000 +++ b/libpurple/plugins/ssl/ssl-gnutls.c Thu Apr 01 05:26:44 2010 +0000 @@ -36,6 +36,7 @@ { gnutls_session session; guint handshake_handler; + guint handshake_timer; } PurpleSslGnutlsData; #define PURPLE_SSL_GNUTLS_DATA(gsc) ((PurpleSslGnutlsData *)gsc->private_data) @@ -367,6 +368,19 @@ } +static gboolean +start_handshake_cb(gpointer data) +{ + PurpleSslConnection *gsc = data; + PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc); + + purple_debug_info("gnutls", "Starting handshake with %s\n", gsc->host); + + gnutls_data->handshake_timer = 0; + + ssl_gnutls_handshake_cb(gsc, gsc->fd, PURPLE_INPUT_READ); + return FALSE; +} static void ssl_gnutls_connect(PurpleSslConnection *gsc) @@ -410,10 +424,8 @@ gnutls_data->handshake_handler = purple_input_add(gsc->fd, PURPLE_INPUT_READ, ssl_gnutls_handshake_cb, gsc); - purple_debug_info("gnutls", "Starting handshake with %s\n", gsc->host); - /* Orborde asks: Why are we configuring a callback, then - immediately calling it? + (almost) immediately calling it? Answer: gnutls_handshake (up in handshake_cb) needs to be called once in order to get the ball rolling on the SSL connection. @@ -424,7 +436,8 @@ and subsequent calls, we'll just fire the callback immediately to accomplish this. */ - ssl_gnutls_handshake_cb(gsc, gsc->fd, PURPLE_INPUT_READ); + gnutls_data->handshake_timer = purple_timeout_add(0, start_handshake_cb, + gsc); } static void @@ -437,6 +450,8 @@ if(gnutls_data->handshake_handler) purple_input_remove(gnutls_data->handshake_handler); + if (gnutls_data->handshake_timer) + purple_timeout_remove(gnutls_data->handshake_timer); gnutls_bye(gnutls_data->session, GNUTLS_SHUT_RDWR);