diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-09-26 15:12:11 +0200 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-09-26 15:12:11 +0200 |
commit | 8e6c7326667f7302bf622555d7c4164d24b89be0 (patch) | |
tree | b335a5da4e4380265166d6b78379c4ddf284b19c /protocols/jabber/iq.c | |
parent | 281859e83eb7c953b64a970d3156279b323617d0 (diff) |
Proper detection of resource changed strings from the server.
Diffstat (limited to 'protocols/jabber/iq.c')
-rw-r--r-- | protocols/jabber/iq.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c index ac5e0932..a7783fcb 100644 --- a/protocols/jabber/iq.c +++ b/protocols/jabber/iq.c @@ -110,12 +110,12 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ) } else if( strcmp( type, "result" ) == 0 && orig ) { - struct xt_node *node; + struct xt_node *c; if( !( jd->flags & JFLAG_AUTHENTICATED ) && - ( node = xt_find_node( orig->children, "query" ) ) && - ( node = xt_find_node( node->children, "username" ) ) && - node->text_len ) + ( c = xt_find_node( orig->children, "query" ) ) && + ( c = xt_find_node( c->children, "username" ) ) && + c->text_len ) { /* This happens when we just successfully authenticated the old (non-SASL) way. */ @@ -123,12 +123,23 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ) if( !jabber_get_roster( gc ) ) return XT_ABORT; } - else if( ( node = xt_find_node( orig->children, "bind" ) ) || - ( node = xt_find_node( orig->children, "session" ) ) ) + /* Tricky: Look for <bind> in the reply, because the server + should confirm the chosen resource string there. For + <session>, however, look in the cache, because the server + will probably not include it in its reply. */ + else if( ( c = xt_find_node( node->children, "bind" ) ) || + ( c = xt_find_node( orig->children, "session" ) ) ) { - if( strcmp( node->name, "bind" ) == 0 ) + if( strcmp( c->name, "bind" ) == 0 ) + { + c = xt_find_node( c->children, "jid" ); + if( c && c->text_len && ( s = strchr( c->text, '/' ) ) && + strcmp( s + 1, set_getstr( &gc->acc->set, "resource" ) ) != 0 ) + serv_got_crap( gc, "Server changed session resource string to `%s'", s + 1 ); + jd->flags &= ~JFLAG_WAIT_BIND; - else if( strcmp( node->name, "session" ) == 0 ) + } + else if( strcmp( c->name, "session" ) == 0 ) jd->flags &= ~JFLAG_WAIT_SESSION; if( ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 ) |