Mercurial > pidgin
diff libpurple/plugins/ssl/ssl-nss.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 | c35fd54ec64b |
children | fc4bacb35cbc |
line wrap: on
line diff
--- a/libpurple/plugins/ssl/ssl-nss.c Thu Apr 01 04:58:17 2010 +0000 +++ b/libpurple/plugins/ssl/ssl-nss.c Thu Apr 01 05:26:44 2010 +0000 @@ -51,7 +51,7 @@ PRFileDesc *fd; PRFileDesc *in; guint handshake_handler; - + guint handshake_timer; } PurpleSslNssData; #define PURPLE_SSL_NSS_DATA(gsc) ((PurpleSslNssData *)gsc->private_data) @@ -368,6 +368,18 @@ } } +static gboolean +start_handshake_cb(gpointer data) +{ + PurpleSslConnection *gsc = data; + PurpleSslNssData *nss_data = PURPLE_SSL_NSS_DATA(gsc); + + nss_data->handshake_timer = 0; + + ssl_nss_handshake_cb(gsc, gsc->fd, PURPLE_INPUT_READ); + return FALSE; +} + static void ssl_nss_connect(PurpleSslConnection *gsc) { @@ -438,7 +450,7 @@ nss_data->handshake_handler = purple_input_add(gsc->fd, PURPLE_INPUT_READ, ssl_nss_handshake_cb, gsc); - ssl_nss_handshake_cb(gsc, gsc->fd, PURPLE_INPUT_READ); + nss_data->handshake_timer = purple_timeout_add(0, start_handshake_cb, gsc); } static void @@ -460,6 +472,9 @@ if (nss_data->handshake_handler) purple_input_remove(nss_data->handshake_handler); + if (nss_data->handshake_timer) + purple_timeout_remove(nss_data->handshake_timer); + g_free(nss_data); gsc->private_data = NULL; }