diff options
author | Daniel Atallah <datallah@pidgin.im> | 2008-05-13 18:56:11 +0000 |
---|---|---|
committer | Daniel Atallah <datallah@pidgin.im> | 2008-05-13 18:56:11 +0000 |
commit | 2cb1c7ee0de38836cfe8d3c8f92109c826fa24eb (patch) | |
tree | a48fe9708db0cec786e8e042cb2d8ddd1ce39246 | |
parent | 2276dce2b50f9b5223bd58f8218a3b3403f3ae80 (diff) | |
parent | 6a16f3a8c27440baead52137ff5249f3596e4581 (diff) | |
download | pidgin-2cb1c7ee0de38836cfe8d3c8f92109c826fa24eb.tar.gz |
merge of '413ccc075f8bceec8fcd94d98793e03f1aba0280'
and 'db14d754108810e192ef19f6dbbfbdd326ec50f0'
-rw-r--r-- | libpurple/protocols/simple/simple.c | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/libpurple/protocols/simple/simple.c b/libpurple/protocols/simple/simple.c index 81006d3bc5..526a4917a5 100644 --- a/libpurple/protocols/simple/simple.c +++ b/libpurple/protocols/simple/simple.c @@ -309,6 +309,12 @@ static char *parse_attribute(const char *attrname, const char *source) { char *retval = NULL; int len = strlen(attrname); + /* we know that source is NULL-terminated. + * Therefore this loop won't be infinite. + */ + while (source[0] == ' ') + source++; + if(!strncmp(source, attrname, len)) { tmp = source + len; tmp2 = g_strstr_len(tmp, strlen(tmp), "\""); @@ -341,7 +347,7 @@ static void fill_auth(struct simple_account_data *sip, const gchar *hdr, struct if(!g_ascii_strncasecmp(hdr, "NTLM", 4)) { purple_debug_info("simple", "found NTLM\n"); auth->type = 2; - parts = g_strsplit(hdr+5, "\", ", 0); + parts = g_strsplit(hdr+5, "\",", 0); i = 0; while(parts[i]) { purple_debug_info("simple", "parts[i] %s\n", parts[i]); @@ -368,30 +374,40 @@ static void fill_auth(struct simple_account_data *sip, const gchar *hdr, struct auth->nc = 1; } else { auth->nc = 3; - } + } + return; - } + } else if(!g_ascii_strncasecmp(hdr, "DIGEST", 6)) { - auth->type = 1; - parts = g_strsplit(hdr, " ", 0); - while(parts[i]) { - if((tmp = parse_attribute("nonce=\"", parts[i]))) { - auth->nonce = tmp; - } - else if((tmp = parse_attribute("realm=\"", parts[i]))) { - auth->realm = tmp; + purple_debug_info("simple", "found DIGEST\n"); + + auth->type = 1; + parts = g_strsplit(hdr+7, ",", 0); + while(parts[i]) { + if((tmp = parse_attribute("nonce=\"", parts[i]))) { + auth->nonce = tmp; + } + else if((tmp = parse_attribute("realm=\"", parts[i]))) { + auth->realm = tmp; + } + i++; } - i++; - } - g_strfreev(parts); + g_strfreev(parts); + purple_debug(PURPLE_DEBUG_MISC, "simple", "nonce: %s realm: %s\n", + auth->nonce ? auth->nonce : "(null)", + auth->realm ? auth->realm : "(null)"); - purple_debug(PURPLE_DEBUG_MISC, "simple", "nonce: %s realm: %s\n", auth->nonce ? auth->nonce : "(null)", auth->realm ? auth->realm : "(null)"); - if(auth->realm) { - auth->digest_session_key = purple_cipher_http_digest_calculate_session_key( + if(auth->realm) { + auth->digest_session_key = purple_cipher_http_digest_calculate_session_key( "md5", authuser, auth->realm, sip->password, auth->nonce, NULL); - auth->nc = 1; + auth->nc = 1; + } + + } else { + purple_debug_error("simple", "Unsupported or bad WWW-Authenticate header (%s).\n", hdr); } + } static void simple_canwrite_cb(gpointer data, gint source, PurpleInputCondition cond) { |