im.pidgin.pidgin: 5268d2ff6deab0c7a6744188ed0062bdeed9cf62

evands at pidgin.im evands at pidgin.im
Mon Nov 19 03:10:37 EST 2007


-----------------------------------------------------------------
Revision: 5268d2ff6deab0c7a6744188ed0062bdeed9cf62
Ancestor: 5778cac11e657bb2127607455807027f7995d06e
Author: evands at pidgin.im
Date: 2007-11-19T08:05:36
Branch: im.pidgin.pidgin

Modified files:
        libpurple/protocols/jabber/jabber.c

ChangeLog: 

The Jabber registration process depends upon having a non-NULL cbdata->who,
which was set only from the 'from' attribute of the registration packet.
I can't find anything in XEP-0077 which discusses whether the 'from' attribute
is required, but I've run into at least one server (bgmn.net, which according to
gmn.ne/jabber is using OpenFire 3.2.4) which doesn't include it. This leads to
registration attempts crashing.

If we can't get a 'from' attribute, try to use the fully qualified domain name
instead.  If that's NULL for some reason, fail the registration attempt rather
than continuing on and crashing.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jabber.c	47e604e161d1be9bd8ccd572e2cce5dc84861c3c
+++ libpurple/protocols/jabber/jabber.c	663fd9b52448a7223e5004b2d490e9d687bd5c87
@@ -749,7 +749,7 @@ jabber_register_cb(JabberRegisterCBData 
 
 	iq = jabber_iq_new_query(cbdata->js, JABBER_IQ_SET, "jabber:iq:register");
 	query = xmlnode_get_child(iq->node, "query");
-	xmlnode_set_attrib(iq->node,"to",cbdata->who);
+	xmlnode_set_attrib(iq->node, "to", cbdata->who);
 
 	for(groups = purple_request_fields_get_groups(fields); groups;
 			groups = groups->next) {
@@ -824,7 +824,7 @@ jabber_register_cb(JabberRegisterCBData 
 		username = g_strdup_printf("%s@%s/%s", cbdata->js->user->node, cbdata->js->user->domain,
 				cbdata->js->user->resource);
 		purple_account_set_username(cbdata->js->gc->account, username);
-	g_free(username);
+		g_free(username);
 	}
 
 	jabber_iq_set_callback(iq, jabber_registration_result_cb, cbdata->who);
@@ -866,7 +866,7 @@ void jabber_register_parse(JabberStream 
 {
 	PurpleAccount *account = purple_connection_get_account(js->gc);
 	const char *type;
-	const char *from = xmlnode_get_attrib(packet, "from");
+	const char *from;
 	PurpleRequestFields *fields;
 	PurpleRequestFieldGroup *group;
 	PurpleRequestField *field;
@@ -878,6 +878,11 @@ void jabber_register_parse(JabberStream 
 	if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result"))
 		return;
 
+	from = xmlnode_get_attrib(packet, "from");
+	if (!from)
+		from = js->serverFQDN;
+	g_return_if_fail(from != NULL);
+	
 	if(js->registration) {
 		/* get rid of the login thingy */
 		purple_connection_set_state(js->gc, PURPLE_CONNECTED);


More information about the Commits mailing list