Don't allow masquerading into oneself (bug #3040)
authorMark Spencer <markster@digium.com>
Sun, 9 Jan 2005 09:42:54 +0000 (09:42 +0000)
committerMark Spencer <markster@digium.com>
Sun, 9 Jan 2005 09:42:54 +0000 (09:42 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4726 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channel.c
channels/chan_sip.c

index bc54a8b..01e9c28 100755 (executable)
--- a/channel.c
+++ b/channel.c
@@ -2208,6 +2208,10 @@ int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clo
 {
        struct ast_frame null = { AST_FRAME_NULL, };
        int res = -1;
+       if (original == clone) {
+               ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n", original->name);
+               return -1;
+       }
        ast_mutex_lock(&original->lock);
        while(ast_mutex_trylock(&clone->lock)) {
                ast_mutex_unlock(&original->lock);
index 173a62c..ec9ccda 100755 (executable)
@@ -5335,9 +5335,13 @@ static int get_refer_info(struct sip_pvt *p, struct sip_request *oreq)
                        p2 = p2->next;
                }
                ast_mutex_unlock(&iflock);
-               if (p->refer_call)
-                       return 0;
-               else
+               if (p->refer_call) {
+                       if (p->refer_call == p) {
+                               ast_log(LOG_NOTICE, "Supervised transfer attempted to transfer into same call id (%s == %s)!\n", tmp5, p->callid);
+                               p->refer_call = NULL;
+                       } else
+                               return 0;
+               } else
                        ast_log(LOG_NOTICE, "Supervised transfer requested, but unable to find callid '%s'\n", tmp5);
        } else if (ast_exists_extension(NULL, p->context, c, 1, NULL) || !strcmp(c, ast_parking_ext())) {
                /* This is an unsupervised transfer */