summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2012-10-04 02:16:43 +0000
committerMatthew Jordan <mjordan@digium.com>2012-10-04 02:16:43 +0000
commit481df22eacb14a6754f12ea1f2014a6e6e79575b (patch)
tree5e72116635562518a5827aa0c715396c9cc5cdbc
parent9367893cff8b69dd070adcce06ca9b5a998188cc (diff)
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. FYI: In Asterisk 11+, you really should be using res_xmpp. It does not have this problem, as it moved to the astobj2 library. 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 ........ Merged revisions 374335 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 374336 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 374337 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@374338 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--res/res_jabber.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/res/res_jabber.c b/res/res_jabber.c
index 0494fd2b0..defdfd934 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -2045,6 +2045,12 @@ static int aji_client_info_handler(void *data, ikspak *pak)
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) {
@@ -2112,6 +2118,12 @@ static int aji_dinfo_handler(void *data, ikspak *pak)
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");
ASTOBJ_UNREF(client, ast_aji_client_destroy);