# HG changeset patch # User Paul Aurich # Date 1274412375 0 # Node ID 09ca9dfb2cfebf2a674a3cb631bf7e9f739008f5 # Parent 23b3627ecec3fd78087e2d82d273f861eba54651 jabber: Fix a case where a broken server would hang the connection. This also fixes a few small leaks and updates a few strings to match scram_handle_challenge(). diff -r 23b3627ecec3 -r 09ca9dfb2cfe libpurple/protocols/jabber/auth_scram.c --- a/libpurple/protocols/jabber/auth_scram.c Fri May 21 02:40:53 2010 +0000 +++ b/libpurple/protocols/jabber/auth_scram.c Fri May 21 03:26:15 2010 +0000 @@ -517,13 +517,24 @@ gsize len; enc_in = xmlnode_get_data(packet); - g_return_val_if_fail(enc_in != NULL && *enc_in != '\0', FALSE); + if (data->step != 3 && (!enc_in || *enc_in == '\0')) { + *error = g_strdup(_("Invalid challenge from server")); + g_free(enc_in); + return JABBER_SASL_STATE_FAIL; + } - if (data->step == 3) + if (data->step == 3) { + /* + * If the server took the slow approach (sending the verifier + * as a challenge/response pair), we get here. + */ + g_free(enc_in); return JABBER_SASL_STATE_OK; + } if (data->step != 2) { *error = g_strdup(_("Unexpected response from server")); + g_free(enc_in); return JABBER_SASL_STATE_FAIL; } @@ -532,7 +543,7 @@ if (!dec_in || len != strlen(dec_in)) { /* Danger afoot; SCRAM shouldn't contain NUL bytes */ g_free(dec_in); - *error = g_strdup(_("Invalid challenge from server")); + *error = g_strdup(_("Malicious challenge from server")); return JABBER_SASL_STATE_FAIL; }