Non capturing parenthesis in regexp causes seg fault.

Arran Cudbard-Bell A.Cudbard-Bell at sussex.ac.uk
Fri Feb 15 19:28:14 CET 2008


Arran Cudbard-Bell wrote:
> Alan DeKok wrote:
>> Arran Cudbard-Bell wrote:
>>  
>>> Hi,
>>>
>>> Got this on my 32bit intel box running Ubuntu Linux 6.10
>>>
>>> if("%{User-Name}" =~ /(?:.*)/){
>>>     
>>
>>   I'm not sure that's a valid regular expression... '?' is usually a
>> modifier...
>>   
> It is...
>
> It allows you to create backreferences but not capture the result 
> directly.
>
> http://www.regular-expressions.info/brackets.html
>
> Pretty sure it's supported with the PCRE library.
man pcre

SUBPATTERNS

       Subpatterns are delimited by parentheses (round brackets), which can be
       nested.  Turning part of a pattern into a subpattern does two things:

       1. It localizes a set of alternatives. For example, the pattern

         cat(aract|erpillar|)

       matches  one  of the words "cat", "cataract", or "caterpillar". Without
       the parentheses, it would match  "cataract",  "erpillar"  or  an  empty
       string.

       2.  It  sets  up  the  subpattern as a capturing subpattern. This means
       that, when the whole pattern  matches,  that  portion  of  the  subject
       string that matched the subpattern is passed back to the caller via the
       ovector argument of pcre_exec(). Opening parentheses are  counted  from
       left  to  right  (starting  from 1) to obtain numbers for the capturing
       subpatterns.

       For example, if the string "the red king" is matched against  the  pat-
       tern

         the ((red|white) (king|queen))

       the captured substrings are "red king", "red", and "king", and are num-
       bered 1, 2, and 3, respectively.

       The fact that plain parentheses fulfil  two  functions  is  not  always
       helpful.   There are often times when a grouping subpattern is required
       without a capturing requirement. If an opening parenthesis is  followed
       by  a question mark and a colon, the subpattern does not do any captur-
       ing, and is not counted when computing the  number  of  any  subsequent
       capturing  subpatterns. For example, if the string "the white queen" is
       matched against the pattern

         the ((?:red|white) (king|queen))

>>  
>>> Program received signal SIGSEGV, Segmentation fault.
>>> [Switching to Thread -1213196608 (LWP 6433)]
>>> 0xb7bc9492 in regexec () from /lib/tls/i686/cmov/libc.so.6
>>> (gdb) bt
>>> #0  0xb7bc9492 in regexec () from /lib/tls/i686/cmov/libc.so.6
>>>     
>>
>>   It might be a bug in the regular expression library...
>>
>>  
>>> #1  0x0806d6a9 in ?? ()
>>>     
>>
>>   Ugh.  2.0.x *should* be built with debugging symbols, and should *not*
>> be stripped of those symbols before being installed.
>>   
> Yes, and this is from CVS. I'll rebuild with the debug flags...
Ok with --enable-developer , it's exactly the same. Grrr
>>   Alan DeKok.
>> -
>> List info/subscribe/unsubscribe? See 
>> http://www.freeradius.org/list/users.html
>>   
>
>
-- 
Arran Cudbard-Bell (A.Cudbard-Bell at sussex.ac.uk)
Authentication, Authorisation and Accounting Officer
Infrastructure Services | ENG1 E1-1-08 
University Of Sussex, Brighton
EXT:01273 873900 | INT: 3900




More information about the Freeradius-Users mailing list