# HG changeset patch # User Daniel Atallah # Date 1155859138 0 # Node ID b1ce2e9e494a9706be9bf98320c7359ffbf33f0d # Parent 4687f862a56b9394988fbf53697b50df11f0c287 [gaim-migrate @ 16820] Fix CID 250 (also change the behavior to be slightly more sane) and 213 (which wouldn't happen unless the sasl library returned some weird values) committer: Tailor Script diff -r 4687f862a56b -r b1ce2e9e494a src/protocols/jabber/auth.c --- a/src/protocols/jabber/auth.c Thu Aug 17 22:42:28 2006 +0000 +++ b/src/protocols/jabber/auth.c Thu Aug 17 23:58:58 2006 +0000 @@ -181,9 +181,9 @@ static void jabber_auth_start_cyrus(JabberStream *js) { - const char *clientout, *mech; + const char *clientout = NULL, *mech = NULL; char *enc_out; - unsigned coutlen; + unsigned coutlen = 0; xmlnode *auth; sasl_security_properties_t secprops; gboolean again; @@ -256,21 +256,29 @@ /* For everything else, fail the mechanism and try again */ default: gaim_debug_info("sasl", "sasl_state is %d, failing the mech and trying again\n", js->sasl_state); - if (strlen(mech)>0) { + + /* + * DAA: is this right? + * The manpage says that "mech" will contain the chosen mechanism on success. + * Presumably, if we get here that isn't the case and we shouldn't try again? + * I suspect that this never happens. + */ + if (mech && strlen(mech) > 0) { char *pos; - pos = strstr(js->sasl_mechs->str,mech); - g_assert(pos!=NULL); - g_string_erase(js->sasl_mechs, pos-js->sasl_mechs->str,strlen(mech)); + if ((pos = strstr(js->sasl_mechs->str, mech)) { + g_string_erase(js->sasl_mechs, pos-js->sasl_mechs->str, strlen(mech)); + } + again = TRUE; } + sasl_dispose(&js->sasl); - again=TRUE; } } while (again); if (js->sasl_state == SASL_CONTINUE || js->sasl_state == SASL_OK) { auth = xmlnode_new("auth"); xmlnode_set_namespace(auth, "urn:ietf:params:xml:ns:xmpp-sasl"); - xmlnode_set_attrib(auth,"mechanism", mech); + xmlnode_set_attrib(auth, "mechanism", mech); if (clientout) { if (coutlen == 0) { xmlnode_insert_data(auth, "=", -1); @@ -332,7 +340,7 @@ char *mech_name = xmlnode_get_data(mechnode); #ifdef HAVE_CYRUS_SASL g_string_append(js->sasl_mechs, mech_name); - g_string_append_c(js->sasl_mechs,' '); + g_string_append_c(js->sasl_mechs, ' '); #else if(mech_name && !strcmp(mech_name, "DIGEST-MD5")) digest_md5 = TRUE;