aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authorphsultan <phsultan@f38db490-d61c-443f-a65b-d21fe96a405b>2007-10-07 15:52:44 +0000
committerphsultan <phsultan@f38db490-d61c-443f-a65b-d21fe96a405b>2007-10-07 15:52:44 +0000
commit78c2fc93f28a4d9fbc114a53abe390d73c7f093b (patch)
tree37ef13b1e513497ca331af318edd785693cf6dd9 /res
parent9167f3ed2cff0ef84c5144062a1a412b69929219 (diff)
Prevent Asterisk from crashing when receiving a presence packet
without resource from a buddy that is known to have a resource list. Revert a change I previously made, where Asterisk could point to a freed memory location. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@84890 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r--res/res_jabber.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/res/res_jabber.c b/res/res_jabber.c
index 8b83731d6..25f741d15 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -1185,7 +1185,7 @@ static void aji_handle_presence(struct aji_client *client, ikspak *pak)
tmp = buddy->resources;
descrip = ast_strdup(iks_find_cdata(pak->x,"status"));
- while (tmp) {
+ while (tmp && pak->from->resource) {
if (!strcasecmp(tmp->resource, pak->from->resource)) {
tmp->status = status;
if (tmp->description) free(tmp->description);
@@ -1258,7 +1258,7 @@ static void aji_handle_presence(struct aji_client *client, ikspak *pak)
}
/* resource not found in our list, create it */
- if (!found && status != 6) {
+ if (!found && status != 6 && pak->from->resource) {
found = (struct aji_resource *) malloc(sizeof(struct aji_resource));
memset(found, 0, sizeof(struct aji_resource));
@@ -1293,12 +1293,6 @@ static void aji_handle_presence(struct aji_client *client, ikspak *pak)
buddy->resources = found;
}
- /* if 'from' attribute does not contain 'resource' string
- point to the top of our resource list */
- if (!found && !pak->from->resource && buddy->resources) {
- found = buddy->resources;
- }
-
ASTOBJ_UNLOCK(buddy);
ASTOBJ_UNREF(buddy, aji_buddy_destroy);
@@ -1311,7 +1305,8 @@ static void aji_handle_presence(struct aji_client *client, ikspak *pak)
ver = iks_find_attrib(iks_find(pak->x, "caps:c"), "ver");
}
- if(status !=6 && !found->cap) {
+ /* retrieve capabilites of the new resource */
+ if(status !=6 && found && !found->cap) {
found->cap = aji_find_version(node, ver, pak);
if(gtalk_yuck(pak->x)) /* gtalk should do discover */
found->cap->jingle = 1;