Fix an issue where a service discovery request could crash Asterisk.

A server sending a service discovery request to us may or may not put a from attribute in the message. If the from attribute is present use it in the to attribute for the result. If the from attribute is not present do not add a to attribute.

(issue ASTERISK-16203)
Reported by: wubbla


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370126 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Joshua Colp 2012-07-16 19:14:29 +00:00
parent 3b59ab1c77
commit fdd39eae58
1 changed files with 10 additions and 3 deletions

View File

@ -2211,7 +2211,11 @@ static int xmpp_client_service_discovery_get_hook(void *data, ikspak *pak)
}
iks_insert_attrib(iq, "from", client->jid->full);
iks_insert_attrib(iq, "to", pak->from->full);
if (pak->from) {
iks_insert_attrib(iq, "to", pak->from->full);
}
iks_insert_attrib(iq, "type", "result");
iks_insert_attrib(iq, "id", pak->id);
iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#info");
@ -3037,8 +3041,11 @@ static int xmpp_pak_presence(struct ast_xmpp_client *client, struct ast_xmpp_cli
}
if (!(buddy = ao2_find(client->buddies, pak->from->partial, OBJ_KEY))) {
ast_log(LOG_WARNING, "Received presence information about '%s' despite not having them in roster on client '%s'\n",
pak->from->partial, client->name);
/* Only output the message if it is not about us */
if (strcmp(client->jid->partial, pak->from->partial)) {
ast_log(LOG_WARNING, "Received presence information about '%s' despite not having them in roster on client '%s'\n",
pak->from->partial, client->name);
}
return 0;
}