# HG changeset patch # User Daniel Atallah # Date 1254500359 0 # Node ID 53bf7fd37cb05436e39252fc1838b3d5e6a48134 # Parent e601e2c5bb9ea3e55ecca65dbc00fd8190b2b60f Prevent a NULL sprintf(%s) when no resource is assigned to an account during inband registration. Fixes #10420. diff -r e601e2c5bb9e -r 53bf7fd37cb0 libpurple/protocols/jabber/jabber.c --- a/libpurple/protocols/jabber/jabber.c Fri Oct 02 13:01:28 2009 +0000 +++ b/libpurple/protocols/jabber/jabber.c Fri Oct 02 16:19:19 2009 +0000 @@ -1077,53 +1077,53 @@ return; } } else { - const char *value = purple_request_field_string_get_value(field); - - if(!strcmp(id, "username")) { - y = xmlnode_new_child(query, "username"); - } else if(!strcmp(id, "password")) { - y = xmlnode_new_child(query, "password"); - } else if(!strcmp(id, "name")) { - y = xmlnode_new_child(query, "name"); - } else if(!strcmp(id, "email")) { - y = xmlnode_new_child(query, "email"); - } else if(!strcmp(id, "nick")) { - y = xmlnode_new_child(query, "nick"); - } else if(!strcmp(id, "first")) { - y = xmlnode_new_child(query, "first"); - } else if(!strcmp(id, "last")) { - y = xmlnode_new_child(query, "last"); - } else if(!strcmp(id, "address")) { - y = xmlnode_new_child(query, "address"); - } else if(!strcmp(id, "city")) { - y = xmlnode_new_child(query, "city"); - } else if(!strcmp(id, "state")) { - y = xmlnode_new_child(query, "state"); - } else if(!strcmp(id, "zip")) { - y = xmlnode_new_child(query, "zip"); - } else if(!strcmp(id, "phone")) { - y = xmlnode_new_child(query, "phone"); - } else if(!strcmp(id, "url")) { - y = xmlnode_new_child(query, "url"); - } else if(!strcmp(id, "date")) { - y = xmlnode_new_child(query, "date"); - } else { - continue; - } - xmlnode_insert_data(y, value, -1); + const char *value = purple_request_field_string_get_value(field); + + if(!strcmp(id, "username")) { + y = xmlnode_new_child(query, "username"); + } else if(!strcmp(id, "password")) { + y = xmlnode_new_child(query, "password"); + } else if(!strcmp(id, "name")) { + y = xmlnode_new_child(query, "name"); + } else if(!strcmp(id, "email")) { + y = xmlnode_new_child(query, "email"); + } else if(!strcmp(id, "nick")) { + y = xmlnode_new_child(query, "nick"); + } else if(!strcmp(id, "first")) { + y = xmlnode_new_child(query, "first"); + } else if(!strcmp(id, "last")) { + y = xmlnode_new_child(query, "last"); + } else if(!strcmp(id, "address")) { + y = xmlnode_new_child(query, "address"); + } else if(!strcmp(id, "city")) { + y = xmlnode_new_child(query, "city"); + } else if(!strcmp(id, "state")) { + y = xmlnode_new_child(query, "state"); + } else if(!strcmp(id, "zip")) { + y = xmlnode_new_child(query, "zip"); + } else if(!strcmp(id, "phone")) { + y = xmlnode_new_child(query, "phone"); + } else if(!strcmp(id, "url")) { + y = xmlnode_new_child(query, "url"); + } else if(!strcmp(id, "date")) { + y = xmlnode_new_child(query, "date"); + } else { + continue; + } + xmlnode_insert_data(y, value, -1); if(cbdata->js->registration && !strcmp(id, "username")) { g_free(cbdata->js->user->node); cbdata->js->user->node = g_strdup(value); - } + } if(cbdata->js->registration && !strcmp(id, "password")) purple_account_set_password(cbdata->js->gc->account, value); + } } } - } if(cbdata->js->registration) { - username = g_strdup_printf("%s@%s/%s", cbdata->js->user->node, cbdata->js->user->domain, - cbdata->js->user->resource); + username = g_strdup_printf("%s@%s%s%s", cbdata->js->user->node, cbdata->js->user->domain, + cbdata->js->user->resource ? "/" : "", cbdata->js->user->resource); purple_account_set_username(cbdata->js->gc->account, username); g_free(username); }