[svn-commits] mjordan: branch 10 r362205 - in /branches/10: ./ channels/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Apr 16 16:57:25 CDT 2012


Author: mjordan
Date: Mon Apr 16 16:57:19 2012
New Revision: 362205

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=362205
Log:
Fix negative return handling in channel drivers

In chan_agent, while handling a channel indicate, the agent channel driver
must obtain a lock on both the agent channel, as well as the channel the
agent channel is using.  To do so, it attempts to lock the other channel
first, then unlock the agent channel which is locked prior to entry into
the indicate handler.  If this unlock fails with a negative return value,
which can occur if the object passed to agent_indicate is an invalid ao2
object or is NULL, the return value is passed directly to strerror, which
can only accept positive integer values.

In chan_dahdi, the return value of dahdi_get_index is used to directly
index into the sub-channel array.  If dahd_get_index returns a negative
value, it would use that value to index into the array, which could cause
an invalid memory access.  If dahdi_get_index returns a negative number,
we now default to SUB_REAL.

(issue ASTERISK-19655)
Reported by: Matt Jordan

Review: https://reviewboard.asterisk.org/r/1863/
........

Merged revisions 362204 from http://svn.asterisk.org/svn/asterisk/branches/1.8

Modified:
    branches/10/   (props changed)
    branches/10/channels/chan_agent.c
    branches/10/channels/chan_dahdi.c

Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/10/channels/chan_agent.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/channels/chan_agent.c?view=diff&rev=362205&r1=362204&r2=362205
==============================================================================
--- branches/10/channels/chan_agent.c (original)
+++ branches/10/channels/chan_agent.c Mon Apr 16 16:57:19 2012
@@ -779,7 +779,7 @@
 		while (ast_channel_trylock(p->chan)) {
 			int res;
 			if ((res = ast_channel_unlock(ast))) {
-				ast_log(LOG_ERROR, "chan_agent bug! Channel was not locked upon entry to agent_indicate: %s\n", strerror(res));
+				ast_log(LOG_ERROR, "chan_agent bug! Channel was not locked upon entry to agent_indicate: %s\n", res > 0 ? strerror(res) : "Bad ao2obj data");
 				ast_mutex_unlock(&p->lock);
 				return -1;
 			}

Modified: branches/10/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/channels/chan_dahdi.c?view=diff&rev=362205&r1=362204&r2=362205
==============================================================================
--- branches/10/channels/chan_dahdi.c (original)
+++ branches/10/channels/chan_dahdi.c Mon Apr 16 16:57:19 2012
@@ -8811,7 +8811,9 @@
 	int usedindex = -1;
 	struct dahdi_pvt *p = ast->tech_pvt;
 
-	idx = dahdi_get_index(ast, p, 1);
+	if ((idx = dahdi_get_index(ast, p, 0)) < 0) {
+		idx = SUB_REAL;
+	}
 
 	p->subs[idx].f.frametype = AST_FRAME_NULL;
 	p->subs[idx].f.datalen = 0;




More information about the svn-commits mailing list