Fix an issue where a service discovery request could crash Asterisk.
authorJoshua Colp <jcolp@digium.com>
Mon, 16 Jul 2012 19:14:29 +0000 (19:14 +0000)
committerJoshua Colp <jcolp@digium.com>
Mon, 16 Jul 2012 19:14:29 +0000 (19:14 +0000)
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

res/res_xmpp.c

index 546243c..91be7af 100644 (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;
        }