[asterisk-commits] irroot: branch irroot/asterisk-trunk-quack-queue r345485 - /team/irroot/aster...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Nov 15 23:19:51 CST 2011


Author: irroot
Date: Tue Nov 15 23:19:37 2011
New Revision: 345485

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=345485
Log:
Eliminate possible seg fault on null ref in ao2 callbacks

Modified:
    team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c

Modified: team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c?view=diff&rev=345485&r1=345484&r2=345485
==============================================================================
--- team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c (original)
+++ team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c Tue Nov 15 23:19:37 2011
@@ -1209,7 +1209,6 @@
 static void pm_load_member_config(struct call_queue *q);
 static struct member *interface_exists(struct call_queue *q, const char *interface);
 static int set_member_paused(const char *queuename, const char *interface, const char *reason, int paused);
-
 static void queue_transfer_fixup(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan);
 
 /*! \brief sets the QUEUESTATUS channel variable */
@@ -1291,9 +1290,13 @@
 static int queue_cmp_cb(void *obj, void *arg, int flags)
 {
 	const struct call_queue *q = obj, *q2 = arg;
-	const char *name = (flags & OBJ_POINTER) ? q2->name : arg;
-
-	return !strcasecmp(q->name, name) ? CMP_MATCH | CMP_STOP : 0;
+	const char *name = (arg && (flags & OBJ_POINTER)) ? q2->name : arg;
+
+	if (!ast_strlen_zero(name) && !strcasecmp(q->name, name)) {
+		return CMP_MATCH | CMP_STOP;
+	} else {
+		return 0;
+	}
 }
 
 /*!
@@ -1317,9 +1320,14 @@
 {
 	const struct queue_data *d = obj, *d2 = arg;
 	const char *name = arg;
-	int qhash = (flags & OBJ_POINTER) ? d2->qhash : ast_str_case_hash(name);
-
-	return  (d->qhash == qhash) ? CMP_MATCH | CMP_STOP : 0;
+	int nhash = (ast_strlen_zero(name)) ? 0 : ast_str_case_hash(name);
+	int qhash = (arg && (flags & OBJ_POINTER)) ? d2->qhash : nhash;
+
+	if (qhash && (d->qhash == qhash)) {
+		return CMP_MATCH | CMP_STOP
+	} else {
+		return 0;
+	}
 }
 
 /*! \brief Set channel variables of queue */
@@ -1736,9 +1744,13 @@
 {
 	const struct member *mem1 = obj1;
 	const struct member *mem2 = obj2;
-	const char *arg = (obj2 && flags & OBJ_POINTER) ? mem2->interface : obj2;
-
-	return strcasecmp(mem1->interface, arg) ? 0 : CMP_MATCH | CMP_STOP;
+	const char *iface = (obj2 && (flags & OBJ_POINTER)) ? mem2->interface : obj2;
+
+	if (!ast_strlen_zero(iface) && !strcasecmp(mem1->interface, iface)) {
+		return CMP_MATCH | CMP_STOP;
+	} else {
+		return 0;
+	}
 }
 
 /*!
@@ -1748,9 +1760,9 @@
 {
 	const struct member *mem1 = obj1;
 	const struct member *mem2 = arg;
-	const char *uniqueid = (flags & OBJ_POINTER) ? mem2->rt_uniqueid : arg;
-
-	if (mem1->realtime && !mem1->dead &&
+	const char *uniqueid = (arg && (flags & OBJ_POINTER)) ? mem2->rt_uniqueid : arg;
+
+	if (mem1->realtime && !mem1->dead && !ast_strlen_zero(uniqueid) &&
 	    !strcasecmp(mem1->rt_uniqueid, uniqueid)) {
 		return CMP_MATCH | CMP_STOP;
 	}
@@ -1826,9 +1838,13 @@
 {
 	const struct mem_state *d = obj;
 	const struct mem_state *d2 = arg;
-	const char *iface = (flags & OBJ_POINTER) ? d2->state_interface : arg;
-
-	return !strcasecmp(d->state_interface, iface) ? CMP_MATCH | CMP_STOP : 0;
+	const char *iface = (arg && (flags & OBJ_POINTER)) ? d2->state_interface : arg;
+
+	if (!ast_strlen_zero(iface) && !strcasecmp(d->state_interface, iface)) {
+		return CMP_MATCH | CMP_STOP;
+	} else {
+		return 0;
+	}
 }
 
 /*!
@@ -1880,9 +1896,13 @@
 {
 	const struct rule_list *rl = obj;
 	const struct rule_list *rl2 = arg;
-	const char *name = (flags & OBJ_POINTER) ? rl2->name : arg;
-
-	return !strcasecmp(rl->name, name) ? CMP_MATCH | CMP_STOP : 0;
+	const char *name = (arg && (flags & OBJ_POINTER)) ? rl2->name : arg;
+
+	if (!ast_strlen_zero(name) && !strcasecmp(rl->name, name)) {
+		return CMP_MATCH | CMP_STOP;
+	} else {
+		return 0;
+	}
 }
 
 /*!
@@ -1905,7 +1925,7 @@
 	const struct callattempt *c = obj;
 	const struct callattempt *c1 = arg;
 	const struct member *mem = (arg) ? c1->member : NULL;
-	const char *interface = (arg && flags & OBJ_POINTER) ? mem->interface : arg;
+	const char *interface = (arg && (flags & OBJ_POINTER)) ? mem->interface : arg;
 
 	if (!arg || ast_strlen_zero(interface) || !strcasecmp(interface, c->member->interface)) {
 		return (c->stillgoing && c->chan) ? CMP_MATCH : 0;
@@ -7285,7 +7305,7 @@
 {
 	struct call_queue *q = obj;
 	const struct call_queue *q2 = arg;
-	const char *queuename = (flags & OBJ_POINTER) ? q2->name : arg;
+	const char *queuename = (arg && (flags & OBJ_POINTER)) ? q2->name : arg;
 
 	if (!q->realtime && (ast_strlen_zero(queuename) || !strcasecmp(queuename, q->name))) {
 		q->dead = 1;
@@ -7302,9 +7322,9 @@
 {
 	struct call_queue *q = obj;
 	const struct call_queue *q2 = arg;
-	const char *queuename = (flags & OBJ_POINTER) ? q2->name : arg;
-
-	if ((ast_strlen_zero(queuename) || !strcasecmp(queuename, q->name)) && q->dead) {
+	const char *queuename = (arg && (flags & OBJ_POINTER)) ? q2->name : arg;
+
+	if (q->dead && (ast_strlen_zero(queuename) || !strcasecmp(queuename, q->name))) {
 		return CMP_MATCH;
 	}
 




More information about the asterisk-commits mailing list