[asterisk-commits] phsultan: trunk r84891 - in /trunk: ./ res/res_jabber.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Oct 7 10:54:49 CDT 2007


Author: phsultan
Date: Sun Oct  7 10:54:48 2007
New Revision: 84891

URL: http://svn.digium.com/view/asterisk?view=rev&rev=84891
Log:
Merged revisions 84890 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r84890 | phsultan | 2007-10-07 17:52:44 +0200 (Sun, 07 Oct 2007) | 5 lines

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.
........

Modified:
    trunk/   (props changed)
    trunk/res/res_jabber.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_jabber.c?view=diff&rev=84891&r1=84890&r2=84891
==============================================================================
--- trunk/res/res_jabber.c (original)
+++ trunk/res/res_jabber.c Sun Oct  7 10:54:48 2007
@@ -1284,7 +1284,7 @@
 	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) ast_free(tmp->description);
@@ -1357,7 +1357,7 @@
 	}
 
 	/* resource not found in our list, create it */
-	if (!found && status != 6) {
+	if (!found && status != 6 && pak->from->resource) {
 		found = ast_calloc(1, sizeof(*found));
 
 		if (!found) {
@@ -1391,12 +1391,6 @@
 			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);
 
@@ -1409,7 +1403,8 @@
 		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;




More information about the asterisk-commits mailing list