regex matching and string >1023 Bytes

Stefan Winter stefan.winter at restena.lu
Fri May 27 08:59:37 CEST 2011


Hm,

that buffer expansion doesn't seem to be sufficient: if I place the
matching text near the beginning, it matches. If it's near the end, it
doesn't. There's a couple of buffer limits on 1024 in xlat.c ; maybe
they need to be expanded, too?

This one:

                Bla  =
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*100*",
                Bla +=
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*200*",
                Bla +=
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*300*",
                Bla +=
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*400*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890zzzz*500*",
                Bla +=
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*600*",
                Bla +=
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*700*",
                Bla +=
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*800*",
                Bla +=
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*900*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1000*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1100*",
                Bla  =
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1200*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1300*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1400*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1500*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1600*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1700*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1800*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1900*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*2000*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*zzzz*"
        }

        if ( "%{control:Bla[*]}" =~ /zzzz/ ) {
                update control {
                        Bla2 := "Hit!"
                }
        }

works (match in line "500"):

++? if ("%{control:Bla[*]}" =~ /zzzz/ )
        expand: %{control:Bla[*]} ->
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*100*
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*200*
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*300*
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*400*
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890zzzz*500*
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*600*
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*700*
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*800*
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*900*
012345678901234567890123456789012345678901234567890123456789012345678901234567890123
? Evaluating ("%{control:Bla[*]}" =~ /zzzz/) -> TRUE
++? if ("%{control:Bla[*]}" =~ /zzzz/ ) -> TRUE

But this one doesn't match, even though it matches on the last line:

                Bla  =
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*100*",
                Bla +=
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*200*",
                Bla +=
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*300*",
                Bla +=
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*400*",
                Bla +=
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*500*",
                Bla +=
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*600*",
                Bla +=
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*700*",
                Bla +=
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*800*",
                Bla +=
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*900*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1000*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1100*",
                Bla  =
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1200*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1300*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1400*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1500*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1600*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1700*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1800*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*1900*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*2000*",
                Bla +=
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123*zzzz*"


++? if ("%{control:Bla[*]}" =~ /zzzz/ )
        expand: %{control:Bla[*]} ->
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*100*
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*200*
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*300*
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*400*
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*500*
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*600*
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*700*
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*800*
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*900*
012345678901234567890123456789012345678901234567890123456789012345678901234567890123
? Evaluating ("%{control:Bla[*]}" =~ /zzzz/) -> FALSE
++? if ("%{control:Bla[*]}" =~ /zzzz/ ) -> FALSE


Am 26.05.2011 14:17, schrieb Alan DeKok:
> Stefan Winter wrote:
>> right, the false positive matches for the regex are now gone, thanks!
>   That's good to hear.
>
>> However, looks like the regex comparison stops after 1023 Bytes, if I
>> actually put a matching pattern beyond that mark, the result keeps being
>> FALSE.
>>
>> Any chance to allow for a longer string?
> $ git pull
>
>   It's a simple fix.
>
>> The concrete use case I have is that group membership attributes are
>> pulled via ldap.attrmap, and if a user is in many groups, checking the
>> group membership with [*] and a regex can easily go beyond 1023 Bytes.
>   A better fix would be to be able to do loop over attributes, doing
> checks for each one.  But that's getting into the area of a real
> programming language...
>
>   Alan DeKok.
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html


-- 
Stefan WINTER
Ingenieur de Recherche
Fondation RESTENA - Réseau Téléinformatique de l'Education Nationale et de la Recherche
6, rue Richard Coudenhove-Kalergi
L-1359 Luxembourg

Tel: +352 424409 1
Fax: +352 422473


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freeradius.org/pipermail/freeradius-devel/attachments/20110527/8f17ada9/attachment.pgp>


More information about the Freeradius-Devel mailing list