]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Resolve duplicate label used in multiple priorities for the same extension.
authorJonathan Rose <jrose@digium.com>
Mon, 5 Dec 2011 15:02:00 +0000 (15:02 +0000)
committerJonathan Rose <jrose@digium.com>
Mon, 5 Dec 2011 15:02:00 +0000 (15:02 +0000)
Prior to this patch, if labels with the same name were used for different priorities in
the same extension, the new label would be accepted, but it would be unusable since
attempts to reach that label would just go to the first one. Now pbx.c detects this,
generates a warning in logs, and culls the label before adding it to the dialplan.

(closes issue ASTERISK-18807)
Reported by: Kenneth Shumard
Patches:
pbx.c.patch uploaded by Kenneth Shumard (License 5077)
........

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

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10@346955 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/pbx.c

index a6338f400b1c642ca0fa3a6b11caa001ea8b6e4a..3c8547a24266612f267ba2348e662a95749bbfa1 100644 (file)
@@ -8276,11 +8276,23 @@ static int add_priority(struct ast_context *con, struct ast_exten *tmp,
 {
        struct ast_exten *ep;
        struct ast_exten *eh=e;
+       int repeated_label = 0; /* Track if this label is a repeat, assume no. */
 
        for (ep = NULL; e ; ep = e, e = e->peer) {
-               if (e->priority >= tmp->priority)
+               if (e->label && tmp->label && e->priority != tmp->priority && !strcmp(e->label, tmp->label)) {
+                       ast_log(LOG_WARNING, "Extension '%s', priority %d in '%s', label '%s' already in use at "
+                                       "priority %d\n", tmp->exten, tmp->priority, con->name, tmp->label, e->priority);
+                       repeated_label = 1;
+               }
+               if (e->priority >= tmp->priority) {
                        break;
+               }
        }
+
+       if (repeated_label) {   /* Discard the label since it's a repeat. */
+               tmp->label = NULL;
+       }
+
        if (!e) {       /* go at the end, and ep is surely set because the list is not empty */
                ast_hashtab_insert_safe(eh->peer_table, tmp);