/pidgin/main: da201c4757d8: jabber: Correctly remove a failed SA...
Daniel Atallah
datallah at pidgin.im
Sat Mar 2 10:55:28 EST 2013
Changeset: da201c4757d8a2be4f35fc08808454846c9bbfe2
Author: Daniel Atallah <datallah at pidgin.im>
Date: 2013-03-02 10:55 -0500
Branch: release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/da201c4757d8
Description:
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
* The space wasn't being removed correctly, causing a failure to try the next
mech with Cyrus-SASL 2.1.25.
* Fixes #15524
diffstat:
libpurple/protocols/jabber/auth_cyrus.c | 41 +++++++++++++++++++-------------
1 files changed, 24 insertions(+), 17 deletions(-)
diffs (73 lines):
diff --git a/libpurple/protocols/jabber/auth_cyrus.c b/libpurple/protocols/jabber/auth_cyrus.c
--- a/libpurple/protocols/jabber/auth_cyrus.c
+++ b/libpurple/protocols/jabber/auth_cyrus.c
@@ -167,7 +167,6 @@ static void
auth_no_pass_cb(PurpleConnection *gc, PurpleRequestFields *fields)
{
PurpleAccount *account;
- JabberStream *js;
/* The password prompt dialog doesn't get disposed if the account disconnects */
if (!PURPLE_CONNECTION_IS_VALID(gc))
@@ -179,6 +178,25 @@ auth_no_pass_cb(PurpleConnection *gc, Pu
purple_account_set_enabled(account, purple_core_get_ui(), FALSE);
}
+static gboolean remove_current_mech(JabberStream *js) {
+ char *pos;
+ if ((pos = strstr(js->sasl_mechs->str, js->current_mech))) {
+ int len = strlen(js->current_mech);
+ /* Clean up space that separated this Mech from the one before or after it */
+ if (pos > js->sasl_mechs->str && *(pos - 1) == ' ') {
+ /* Handle removing space before when current_mech isn't the first mech in the list */
+ pos--;
+ len++;
+ } else if (strlen(pos) > len && *(pos + len) == ' ') {
+ /* Handle removing space after */
+ len++;
+ }
+ g_string_erase(js->sasl_mechs, pos - js->sasl_mechs->str, len);
+ return TRUE;
+ }
+ return FALSE;
+}
+
static JabberSaslState
jabber_auth_start_cyrus(JabberStream *js, xmlnode **reply, char **error)
{
@@ -300,14 +318,8 @@ jabber_auth_start_cyrus(JabberStream *js
* supported mechanisms. This code handles that case
*/
if (js->current_mech && *js->current_mech) {
- char *pos;
- if ((pos = strstr(js->sasl_mechs->str, js->current_mech))) {
- g_string_erase(js->sasl_mechs, pos-js->sasl_mechs->str, strlen(js->current_mech));
- }
- /* Remove space which separated this mech from the next */
- if ((js->sasl_mechs->str)[0] == ' ') {
- g_string_erase(js->sasl_mechs, 0, 1);
- }
+ remove_current_mech(js);
+ /* Should we only try again if we've removed the mech? */
again = TRUE;
}
@@ -546,15 +558,10 @@ jabber_cyrus_handle_failure(JabberStream
{
if (js->auth_fail_count++ < 5) {
if (js->current_mech && *js->current_mech) {
- char *pos;
- if ((pos = strstr(js->sasl_mechs->str, js->current_mech))) {
- g_string_erase(js->sasl_mechs, pos-js->sasl_mechs->str, strlen(js->current_mech));
- }
- /* Remove space which separated this mech from the next */
- if ((js->sasl_mechs->str)[0] == ' ') {
- g_string_erase(js->sasl_mechs, 0, 1);
- }
+ remove_current_mech(js);
}
+
+ /* Should we only try again if we've actually removed a mech? */
if (*js->sasl_mechs->str) {
/* If we have remaining mechs to try, do so */
sasl_dispose(&js->sasl);
More information about the Commits
mailing list