aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralecdavis <alecdavis@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-20 23:16:45 +0000
committeralecdavis <alecdavis@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-20 23:16:45 +0000
commit786a3430ff1a96f168f8d094547e3195b44fe0e7 (patch)
tree66c5d2a7c112e45348785faa23b4974dec7cf8dd
parent28795d7d71f905c9a18a04520dba0c5a509bc33d (diff)
ast_channel_masquerade: Avoid recursive masquerades.
Check all 4 combinations of (original/clonechan) * (masq/masqr). Initially original->masq and clonechan->masqr were only checked. It's possible with multiple masq's planned - and not yet executed, that the 'original' chan could already have another masq'd into it - thus original->masqr would be set, that masqr would lost. Likewise for the clonechan->masq. (closes issue #16057;#17363) Reported by: amorsen;davidw,alecdavis Patches: based on bug16057.diff4.txt uploaded by alecdavis (license 585) Tested by: ramonpeek, davidw, alecdavis git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@287685 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--main/channel.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/main/channel.c b/main/channel.c
index dc77a21e7..977825029 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -4497,19 +4497,27 @@ retrymasq:
ast_debug(1, "Planning to masquerade channel %s into the structure of %s\n",
clonechan->name, original->name);
- if (original->masq) {
- ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
- original->masq->name, original->name);
- } else if (clonechan->masqr) {
- ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
- clonechan->name, clonechan->masqr->name);
- } else {
+
+ if (!original->masqr && !original->masq && !clonechan->masq && !clonechan->masqr) {
original->masq = clonechan;
clonechan->masqr = original;
ast_queue_frame(original, &ast_null_frame);
ast_queue_frame(clonechan, &ast_null_frame);
ast_debug(1, "Done planning to masquerade channel %s into the structure of %s\n", clonechan->name, original->name);
res = 0;
+ } else if (original->masq) {
+ ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
+ original->masq->name, original->name);
+ } else if (original->masqr) {
+ /* not yet as a previously planned masq hasn't yet happened */
+ ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
+ original->name, original->masqr->name);
+ } else if (clonechan->masq) {
+ ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
+ clonechan->masq->name, clonechan->name);
+ } else { /* (clonechan->masqr) */
+ ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
+ clonechan->name, clonechan->masqr->name);
}
ast_channel_unlock(clonechan);