summaryrefslogtreecommitdiff
path: root/main/channel.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2013-04-22 16:44:21 +0000
committerRichard Mudgett <rmudgett@digium.com>2013-04-22 16:44:21 +0000
commitc137d1211154427b8cbcdfc499b54556db6c79b2 (patch)
treee4ed28879161db70d5084ede91b4815e6b42fafc /main/channel.c
parente05870ccae05a9d1ccefd093b4be892c9b7b33b1 (diff)
Fix crash when AMI redirect action redirects two channels out of a bridge.
The two party bridging loops were changing the bridge peer pointers without the channel locks held. Thus when ast_channel_massquerade() tested and used the pointer there is a small window of opportunity for the pointers to become NULL even though the masquerade code has the channels locked. (closes issue ASTERISK-21356) Reported by: William luke Patches: jira_asterisk_21356_v11.patch (license #5621) patch uploaded by rmudgett Tested by: William luke ........ Merged revisions 386256 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 386286 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@386289 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/channel.c')
-rw-r--r--main/channel.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/main/channel.c b/main/channel.c
index 415af35e2..577ab03ae 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -7516,8 +7516,11 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
if (ast_channel_softhangup_internal_flag(c1) & AST_SOFTHANGUP_UNBRIDGE) {
ast_channel_clear_softhangup(c1, AST_SOFTHANGUP_UNBRIDGE);
}
+ ast_channel_lock_both(c0, c1);
ast_channel_internal_bridged_channel_set(c0, c1);
ast_channel_internal_bridged_channel_set(c1, c0);
+ ast_channel_unlock(c0);
+ ast_channel_unlock(c1);
}
continue;
}
@@ -7799,8 +7802,11 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
}
/* Keep track of bridge */
+ ast_channel_lock_both(c0, c1);
ast_channel_internal_bridged_channel_set(c0, c1);
ast_channel_internal_bridged_channel_set(c1, c0);
+ ast_channel_unlock(c0);
+ ast_channel_unlock(c1);
ast_set_owners_and_peers(c0, c1);
@@ -7896,8 +7902,11 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
if (ast_channel_softhangup_internal_flag(c1) & AST_SOFTHANGUP_UNBRIDGE) {
ast_channel_clear_softhangup(c1, AST_SOFTHANGUP_UNBRIDGE);
}
+ ast_channel_lock_both(c0, c1);
ast_channel_internal_bridged_channel_set(c0, c1);
ast_channel_internal_bridged_channel_set(c1, c0);
+ ast_channel_unlock(c0);
+ ast_channel_unlock(c1);
}
/* Stop if we're a zombie or need a soft hangup */
@@ -7990,8 +7999,11 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
ast_indicate(c0, AST_CONTROL_SRCUPDATE);
ast_indicate(c1, AST_CONTROL_SRCUPDATE);
+ ast_channel_lock_both(c0, c1);
ast_channel_internal_bridged_channel_set(c0, NULL);
ast_channel_internal_bridged_channel_set(c1, NULL);
+ ast_channel_unlock(c0);
+ ast_channel_unlock(c1);
manager_bridge_event(0, 1, c0, c1);
ast_debug(1, "Bridge stops bridging channels %s and %s\n", ast_channel_name(c0), ast_channel_name(c1));