# HG changeset patch # User Ma Yuan # Date 1156215314 0 # Node ID bffd1b96207cf4cbd6ba65d95d35ab149e333984 # Parent 78fea55152219d39387bc9005beda87717468ffd [gaim-migrate @ 16968] fix the foolish code of processing the "USR TWN S"'s fs string add some comment committed by Ma Yuan committer: Ethan Blanton diff -r 78fea5515221 -r bffd1b96207c src/protocols/msn/nexus.c --- a/src/protocols/msn/nexus.c Mon Aug 21 18:58:31 2006 +0000 +++ b/src/protocols/msn/nexus.c Tue Aug 22 02:55:14 2006 +0000 @@ -163,7 +163,8 @@ MsnSoapConn *soapconn; MsnNexus * nexus; MsnSession *session; - char *ru,*lc,*id,*tw,*ct,*kpp,*kv,*ver,*rn,*tpf,*fs; + char *ru,*lc,*id,*tw,*ct,*kpp,*kv,*ver,*rn,*tpf; + char *fs0,*fs; char *username, *password; char *request_str, *head, *tail,*challenge_str; @@ -187,15 +188,20 @@ lc = (char *)g_hash_table_lookup(nexus->challenge_data, "lc"); id = (char *)g_hash_table_lookup(nexus->challenge_data, "id"); tw = (char *)g_hash_table_lookup(nexus->challenge_data, "tw"); - fs = (char *)g_hash_table_lookup(nexus->challenge_data, "fs"); + fs0= (char *)g_hash_table_lookup(nexus->challenge_data, "fs"); ru = (char *)g_hash_table_lookup(nexus->challenge_data, "ru"); ct = (char *)g_hash_table_lookup(nexus->challenge_data, "ct"); kpp= (char *)g_hash_table_lookup(nexus->challenge_data, "kpp"); kv = (char *)g_hash_table_lookup(nexus->challenge_data, "kv"); - ver= (char *)g_hash_table_lookup(nexus->challenge_data, "ver"); - rn = (char *)g_hash_table_lookup(nexus->challenge_data, "rn"); + ver= (char *)g_hash_table_lookup(nexus->challenge_data, "ver"); + rn = (char *)g_hash_table_lookup(nexus->challenge_data, "rn"); tpf= (char *)g_hash_table_lookup(nexus->challenge_data, "tpf"); + /* + * add some fail-safe code to avoid windows Gaim Crash bug #1540454 + * If any of these string is NULL, will return Authentication Fail! + * for when windows g_strdup_printf() implementation get NULL point,It crashed! + */ if(!(lc && id && tw && ru && ct && kpp && kv && ver && tpf)){ gaim_debug_error("MaYuan","WLM Authenticate Key Error!\n"); msn_session_set_error(session, MSN_ERROR_AUTH, _("Windows Live ID authentication Failed")); @@ -207,16 +213,20 @@ return; } - if(!fs){ - fs =g_strdup("1"); + /* + * in old MSN NS server's "USR TWN S" return,didn't include fs string + * so we use a default "1" for fs. + */ + if(fs0){ + fs = g_strdup(fs0); + }else{ + fs = g_strdup("1"); } challenge_str = g_strdup_printf( "lc=%s&id=%s&tw=%s&fs=%s&ru=%s&ct=%s&kpp=%s&kv=%s&ver=%s&rn=%s&tpf=%s\r\n", lc,id,tw,fs,ru,ct,kpp,kv,ver,rn,tpf ); - if(!fs){ - g_free(fs); - } + g_free(fs); /*build the SOAP windows Live ID XML body */ tail = g_strdup_printf(TWN_ENVELOP_TEMPLATE,username,password,challenge_str ); @@ -230,7 +240,7 @@ "Content-Length: %d\r\n" "Connection: Keep-Alive\r\n" "Cache-Control: no-cache\r\n\r\n", - soapconn->login_path,soapconn->login_host,strlen(tail)); + soapconn->login_path,soapconn->login_host,(int)strlen(tail)); request_str = g_strdup_printf("%s%s", head,tail); // gaim_debug_misc("msn", "TWN Sending: {%s}\n", request_str);