[asterisk-bugs] [Asterisk 0012473]: [patch] loopback switch does not allow modification of extension

noreply at bugs.digium.com noreply at bugs.digium.com
Fri May 2 10:59:25 CDT 2008


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=12473 
====================================================================== 
Reported By:                chappell
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   12473
Category:                   PBX/pbx_loopback
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     feedback
Asterisk Version:           1.4.19 
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Disclaimer on File?:        N/A 
Request Review:              
====================================================================== 
Date Submitted:             04-18-2008 09:21 CDT
Last Modified:              05-02-2008 10:59 CDT
====================================================================== 
Summary:                    [patch] loopback switch does not allow modification
of extension
Description: 
Due to incorrect use of the AST_LIST_INSERT_HEAD() macro the loopback
switch cannot perform any translation on the extension number before
searching for it in the target context.

====================================================================== 

---------------------------------------------------------------------- 
 chappell - 05-02-08 10:59  
---------------------------------------------------------------------- 
I fixed this bug about 11 months ago so my memory of why I removed those
three lines is a little hazy, but I do remember that I removed them after
extensive debugging.  After studying the code for a while I believe it is
because they represent an test which is invalid in context.

You will note that the surrounding functions such as loopback_canmatch()
have a similar test.  In those functions the purpose of the test is to
prevent the switch from firing unless the source extension matches the
extramatch pattern.  The test is appropriate in those functions, though for
reasons of efficiency the two tests should probably be applied in the
opposite order, like so:

static int loopback_exists(struct ast_channel *chan, const char *context,
const char *exten, int priority, co
{
        LOOPBACK_COMMON;
callerid);
        if (newpattern && !ast_extension_match(newpattern, exten))
                res = 0;
        else 
                res = ast_exists_extension(chan, newcontext, newexten,
newpriority, callerid);
        return res; 
}

But, if I understand the role of loopback_exec() correctly, at the point
at which it applies the test the switch has _already_ fired and the current
extension (to which the test is now applied) is the _target_ extension.
Thus the extramatch test is now erroneously applied to the target extension
which, if the extension has been modified, may not match.  Setting res to
-1 causes something bad to happen.  As I recall, the bad thing is an
erroneous hangup of the channel.

Not only is the test incorrectly applied, it appears to be unnecessary
since at the point at which loopback_exec() is called it has already been
determined that the switch should fire.

So, my patch fixes two bugs.  Both cause things like this:

[dundi-e164-customers]
lswitch => Loopback/${EXTEN:1}@dids/_1.

to fail.  (The purpose of this dialplan fragment is to advertise a context
full of 10-digit NANP numbers using DUNDi.)  The first bug prevents the
switch from ever firing because ${EXTEN:1} evaluations to "" (due to
incorrect construction of the linked list) which is replaced with ${EXTEN}
(by code which does not use the defective linked list) which doesn't match
anything in context [dids].  Once we fix the first bug, the second bug
causes a hangup because after the switch rewrites say 18605551212 to
8605551212 the rewritten number no longer matches _1. 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
05-02-08 10:59  chappell       Note Added: 0086314                          
======================================================================




More information about the asterisk-bugs mailing list