Mercurial > pidgin
diff libpurple/protocols/msn/nexus.c @ 25452:6a0304f317cf
I was hoping this wouldn't be necessary, but it seems that the possibility
has increased now that we update the display name in the AB.
If two SOAP requests fail because of outdated tokens for the same server,
it's possible that the second one could fail miserably. That's because both
times, the update request would be made with the original cipher secret.
However, the response for the first request would overwrite this secret,
and the second response would attempt decryption with this new secret
instead of the original.
Now, we queue up the callbacks if a token-update is already in progress.
This results in a single update if there happens to be multiple failures at
a time, and it stops this incorrect decryption problem.
Fixes #8415.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sun, 15 Feb 2009 02:11:58 +0000 |
parents | 25667ca518d6 |
children | 3f6dbc414357 |
line wrap: on
line diff
--- a/libpurple/protocols/msn/nexus.c Sun Feb 15 02:02:57 2009 +0000 +++ b/libpurple/protocols/msn/nexus.c Sun Feb 15 02:11:58 2009 +0000 @@ -235,6 +235,10 @@ struct _MsnNexusUpdateData { MsnNexus *nexus; int id; +}; + +typedef struct _MsnNexusUpdateCallback MsnNexusUpdateCallback; +struct _MsnNexusUpdateCallback { GSourceFunc cb; gpointer data; }; @@ -428,6 +432,7 @@ char *nonce; gsize len; char *key; + GSList *updates; #if 0 char *decrypted_pp; @@ -489,8 +494,15 @@ g_free(decrypted_data); } - if (ud->cb) - purple_timeout_add(0, ud->cb, ud->data); + updates = nexus->tokens[ud->id].updates; + nexus->tokens[ud->id].updates = NULL; + while (updates != NULL) { + MsnNexusUpdateCallback *update = updates->data; + if (update->cb) + purple_timeout_add(0, update->cb, update->data); + g_free(update); + updates = g_slist_delete_link(updates, updates); + } g_free(ud); } @@ -500,6 +512,7 @@ { MsnSession *session = nexus->session; MsnNexusUpdateData *ud; + MsnNexusUpdateCallback *update; PurpleCipherContext *sha1; PurpleCipherContext *hmac; @@ -526,16 +539,31 @@ char *request; MsnSoapMessage *soap; - purple_debug_info("msn", - "Updating ticket for user '%s' on domain '%s'\n", - purple_account_get_username(session->account), - ticket_domains[id][SSO_VALID_TICKET_DOMAIN]); + update = g_new0(MsnNexusUpdateCallback, 1); + update->cb = cb; + update->data = data; + + if (nexus->tokens[id].updates != NULL) { + /* Update already in progress. Just add to list and return. */ + purple_debug_info("msn", + "Ticket update for user '%s' on domain '%s' in progress. Adding request to queue.\n", + purple_account_get_username(session->account), + ticket_domains[id][SSO_VALID_TICKET_DOMAIN]); + nexus->tokens[id].updates = g_slist_prepend(nexus->tokens[id].updates, + update); + return; + } else { + purple_debug_info("msn", + "Updating ticket for user '%s' on domain '%s'\n", + purple_account_get_username(session->account), + ticket_domains[id][SSO_VALID_TICKET_DOMAIN]); + nexus->tokens[id].updates = g_slist_prepend(nexus->tokens[id].updates, + update); + } ud = g_new0(MsnNexusUpdateData, 1); ud->nexus = nexus; ud->id = id; - ud->cb = cb; - ud->data = data; sha1 = purple_cipher_context_new_by_name("sha1", NULL);