Problem with setting substring match variables (%{1} etc.)

Alan DeKok aland at
Wed Aug 8 16:03:08 CEST 2007

Enrik Berkhan wrote:
> The expression ^(a|b)?(.)$ will match for example 'ax', 'bx', and 'x'.
> The first two cases will work like expected setting %{1} = 'a', %{2} =
> 'x' and so on. In the last case, the first substring is actually empty
> with rxmatch[1].rm_so == -1, but the second substring contains 'x'
> (rxmatch[2].rm_so == 0, rxmatch[2].rm_eo == 1).

  I wasn't aware of that feature of the regex API.

> The code setting the substring match variables stops on the first
> rxmatch[].rm_so == -1 unless the variable has an old value(?), so %{2}
> might be never set in the last example.

  Yup.  It looks like the code should just check *all* of the rxmatch[]

> Is this expected behaviour? If not, how can this be fixed? Just leave
> out the 'break' in the for loop? (Code from valuepair.c)

  Likely, yes.

  If that works, please say so, and I'll commit a patch.  I'm a little
overloaded right now, and can't look at it myself.

  Alan DeKok.

More information about the Freeradius-Devel mailing list