[asterisk-bugs] [Asterisk 0014576]: ENUMLOOKUP - broken regex.

Asterisk Bug Tracker noreply at bugs.digium.com
Fri Mar 6 11:19:57 CST 2009


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=14576 
====================================================================== 
Reported By:                chris-mac
Assigned To:                dvossel
====================================================================== 
Project:                    Asterisk
Issue ID:                   14576
Category:                   Functions/func_enum
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     assigned
Asterisk Version:           SVN 
Regression:                 No 
SVN Branch (only for SVN checkouts, not tarball releases): 1.6.1 
SVN Revision (number only!): 178608 
Request Review:              
====================================================================== 
Date Submitted:             2009-03-01 15:56 CST
Last Modified:              2009-03-06 11:19 CST
====================================================================== 
Summary:                    ENUMLOOKUP - broken regex.
Description: 
The following number +44800123123 is registered with e164.org.

$ dig 3.2.1.3.2.1.0.0.8.4.4.e164.org naptr
returns:
....
3.2.1.3.2.1.0.0.8.4.4.e164.org. 11 IN   NAPTR   200 10 "u" "E2U+SIP"
"!^\\+44800(.*)$!sip:44800\\1 at selfnet.at!" .

so in theory it should translate to: sip:44800123123 at selfnet.at

But the following dialplan function:
exten => _X.,n,Set(ENUM_URI=${ENUMLOOKUP(+44800123123,sip,s,,e164.org)})
exten => _X.,n,NoOp(Enum URI: ${ENUM_URI})

returns: 

... "Enum URI: 4480044800123123 at selfnet.at") in new stack


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

---------------------------------------------------------------------- 
 (0101309) svnbot (reporter) - 2009-03-06 11:19
 http://bugs.digium.com/view.php?id=14576#c101309 
---------------------------------------------------------------------- 
Repository: asterisk
Revision: 180532

U   branches/1.4/main/enum.c

------------------------------------------------------------------------
r180532 | dvossel | 2009-03-06 11:19:55 -0600 (Fri, 06 Mar 2009) | 9 lines

Fix handling of backreferences for ENUM lookups

enum.c did not handle regex backtraces correctly.  The '\1' in the regex
is a backreference that requires a pattern match to be inserted.  The way
the code used to work is that it would find the backreference and insert
the entire input string minus the '+'.  This is incorrect.  The regexec()
function takes in a variable called pmatch which is an array of structs
containing the start and end indexes for each backreference substring.  The
original code actually passed the pmatch array pointer into regexec but
never did anything with it.  Now when a backtrace is found, the backtrace
number is looked up in the pmatch array and the correct substring is
inserted.

(closes issue http://bugs.digium.com/view.php?id=14576)
Reported by: chris-mac
Review: http://reviewboard.digium.com/r/187/


------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=180532 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-03-06 11:19 svnbot         Checkin                                      
2009-03-06 11:19 svnbot         Note Added: 0101309                          
======================================================================




More information about the asterisk-bugs mailing list