diff libgaim/protocols/jabber/auth.c @ 15108:24b19f0d25de

[gaim-migrate @ 17894] hopefully fix the jabber crash people are seeing, and plug a small memory leak committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Mon, 04 Dec 2006 12:52:18 +0000
parents bc440018e208
children ffec45ff82d0
line wrap: on
line diff
--- a/libgaim/protocols/jabber/auth.c	Mon Dec 04 11:36:31 2006 +0000
+++ b/libgaim/protocols/jabber/auth.c	Mon Dec 04 12:52:18 2006 +0000
@@ -716,6 +716,7 @@
 
 		js->sasl_state = sasl_client_step(js->sasl, (char*)dec_in, declen,
 						  NULL, &c_out, &clen);
+		g_free(enc_in);
 		g_free(dec_in);
 		if (js->sasl_state != SASL_CONTINUE && js->sasl_state != SASL_OK) {
 			gaim_debug_error("jabber", "Error is %d : %s\n",js->sasl_state,sasl_errdetail(js->sasl));
@@ -753,9 +754,20 @@
 	 * should try one more round against it
 	 */
 	if (js->sasl_state != SASL_OK) {
+		char *enc_in = xmlnode_get_data(packet);
+		unsigned char *dec_in = NULL;
 		const char *c_out;
 		unsigned int clen;
-		js->sasl_state = sasl_client_step(js->sasl, NULL, 0, NULL, &c_out, &clen);
+		gsize declen = 0;
+
+		if(enc_in != NULL)
+			dec_in = gaim_base64_decode(enc_in, &declen);
+
+		js->sasl_state = sasl_client_step(js->sasl, (char*)dec_in, declen, NULL, &c_out, &clen);
+
+		g_free(enc_in);
+		g_free(dec_in);
+
 		if (js->sasl_state != SASL_OK) {
 			/* This should never happen! */
 			gaim_connection_error(js->gc, _("Invalid response from server."));