[asterisk-commits] mjordan: branch 1.8 r374335 - /branches/1.8/res/res_jabber.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Oct 3 21:09:46 CDT 2012


Author: mjordan
Date: Wed Oct  3 21:09:43 2012
New Revision: 374335

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=374335
Log:
Check for presence of buddy in info/dinfo handlers

The res_jabber resource module uses the ASTOBJ library for managing its ref
counted objects.  After calling ASTOBJ_CONTAINER_FIND to locate a buddy object,
the pointer to the object has to be checked to see if the buddy existed.
Prior to this patch, the buddy object was not checked for NULL; with this patch
in both aji_client_info_handler and aji_dinfo_handler the pointer is checked
before used and, if no buddy object was found, the handlers return an error
code.

This patch does not take the approach that our JID can be used to log in from
another resource.  If that approach is desired, an improvement could be made to
this patch to create the buddy on the fly.  This patch seeks only to prevent
Asterisk from crashing.

Note that multiple people have proposed patches for this issue; the patch being
committed here is based on those.

(closes issue ASTERISK-19532)
Reported by: Karsten Wemheuer
Tested by: Byron Clark
patches:
  fix-jabber uploaded by Karsten Wemheuer (license #5930)
  xmpp_no_crash_with_ejabberd.patch uploaded by Byron Clark (license #6157)

(closes issue ASTERISK-19557)
Reported by: ulugutz


Modified:
    branches/1.8/res/res_jabber.c

Modified: branches/1.8/res/res_jabber.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/res/res_jabber.c?view=diff&rev=374335&r1=374334&r2=374335
==============================================================================
--- branches/1.8/res/res_jabber.c (original)
+++ branches/1.8/res/res_jabber.c Wed Oct  3 21:09:43 2012
@@ -2004,6 +2004,12 @@
 	struct aji_resource *resource = NULL;
 	struct aji_buddy *buddy = ASTOBJ_CONTAINER_FIND(&client->buddies, pak->from->partial);
 
+	if (!buddy) {
+		ast_log(LOG_NOTICE, "JABBER: Received client info from unknown buddy: %s.\n", pak->from->full);
+		ASTOBJ_UNREF(client, ast_aji_client_destroy);
+		return IKS_FILTER_EAT;
+	}
+
 	resource = aji_find_resource(buddy, pak->from->resource);
 	if (pak->subtype == IKS_TYPE_RESULT) {
 		if (!resource) {
@@ -2070,6 +2076,12 @@
 	char *node = NULL;
 	struct aji_resource *resource = NULL;
 	struct aji_buddy *buddy = ASTOBJ_CONTAINER_FIND(&client->buddies, pak->from->partial);
+
+	if (!buddy) {
+		ast_log(LOG_NOTICE, "JABBER: Received client info from unknown buddy: %s.\n", pak->from->full);
+		ASTOBJ_UNREF(client, ast_aji_client_destroy);
+		return IKS_FILTER_EAT;
+	}
 
 	if (pak->subtype == IKS_TYPE_ERROR) {
 		ast_log(LOG_WARNING, "Received error from a client, turn on jabber debug!\n");




More information about the asterisk-commits mailing list