Regex match on a variable is not working if length is long

Chinnapaiyan, Nagamani Nagamani.Chinnapaiyan at viasat.com
Thu Dec 12 11:25:11 CET 2019


Thanks Alan and Arran,

>  One possibility is to fix the expression.  You're not using the capture groups, so there's no need to the regex engine to store them.

>  You should be able to use:

>       if (&control:Tmp-String-7 =~ /vendor-options.*\(number 43\)\(value (?:(?:[0-9a-fA-F]{2}:)*[0-9a-fA-F]{2})/ ) {

I am using the outer capture group but not the inner one. After removing inner group from capture group, the existing code itself worked.

(0)        if ( "%{control:Tmp-String-7}" =~ /vendor-options.*\(number 43\)\(value ((?:[0-9a-fA-F]{2}:)*[0-9a-fA-F]{2})/ ) {
(0)          EXPAND %{control:Tmp-String-7}
(0)             --> ((ClassName Policy)(name client-policy:1,6,00:A0:BC:6C:7D:3A)(v4-reply-options [vendor-encapsulated-options])(vendor-options [((ClassName Option)(number 43)(value 01:03:00:A0:BC:02:09:55:54:00:00:00:00:00:00:07:03:0E:55:54:32:00:00:00:00:00:03:07:03:0A:00:09:04:11:55:54:5F:33:2E:37:2E:33:2E:31:30:2E:39:2E:62:69:6E:05:04:0A:4F:FF:0F:14:44:01:00:02:01:03:11:05:00:44:00:44:07:00:43:00:43:01:01:02:01:03:06:07:01:BD:01:BD:01:01:02:01:07:00:87:00:88:01:01:02:01:06:C0:A8:64:00:18:07:00:16:00:17:01:01:02:01:03:11:06:C0:A8:64:00:18:07:00:A1:00:A1:19:01:01:26:42:68:74:74:70:3A:2F:2F:61:63:73:2E:64:65:76:2E:63:6D:74:2E:76:69:61:73:61:74:2E:69:6F:3A:39:36:37:35:2F:6C:69:76:65:2F:43:50:45:4D:61:6E:61:67:65:72:2F:43:50:45:73:2F:67:65:6E:65:72:69:63:54:52:36:39:27:02:00:05:28:02:07:D0:2A:0E:55:54:2E:35:2E:32:2E:32:2E:31:30:35:30:33:2B:04:0A:4F:FF:0F:2C:0E:55:54:2E:35:2E:32:2E:32:2E:31:30:33:39:33:33:0C:55:54:32:00:00:00:00:00:00:00:29:08:36:01:FF:3B:0E:55:54:32:00:00:00:00:00:03:07:03:0A:00:09:3C:12:55:54:32:5F:33:2E:37:2E:33:2E:31:30:2E:39:2E:62:69:6E:3D:04:0A:4F:FF:0F:3E:3C:68:74:74:70:3A:2F:2F:31:30:2E:37:39:2E:32:35:35:2E:31:36:2F:70:75:62:2F:76:77:61:5F:69:6D:61:67:65:73:2F:76:77:61:5F:55:54:2E:35:2E:32:2E:32:2E:31:30:35:30:33:2E:74:61:72:2E:67:7A:3F:3C:68:74:74:70:3A:2F:2F:31:30:2E:37:39:2E:32:35:35:2E:31:36:2F:70:75:62:2F:76:77:61:5F:69:6D:61:67:65:73:2F:76:77:61:5F:55:54:2E:35:2E:32:2E:32:2E:31:30:33:39:33:2E:74:61:72:2E:67:7A:40:01:00)(option-definition-set-name ViasatUT))]))
(0)          update control {
(0)            EXPAND %{sub::  }
(0)                  (%{sub::  01:03:00:A0:BC:02:09:55:54:00:00:00:00:00:00:07:03:0E:55:54:32:00:00:00:00:00:03:07:03:0A:00:09:04:11:55:54:5F:33:2E:37:2E:33:2E:31:30:2E:39:2E:62:69:6E:05:04:0A:4F:FF:0F:14:44:01:00:02:01:03:11:05:00:44:00:44:07:00:43:00:43:01:01:02:01:03:06:07:01:BD:01:BD:01:01:02:01:07:00:87:00:88:01:01:02:01:06:C0:A8:64:00:18:07:00:16:00:17:01:01:02:01:03:11:06:C0:A8:64:00:18:07:00:A1:00:A1:19:01:01:26:42:68:74:74:70:3A:2F:2F:61:63:73:2E:64:65:76:2E:63:6D:74:2E:76:69:61:73:61:74:2E:69:6F:3A:39:36:37:35:2F:6C:69:76:65:2F:43:50:45:4D:61:6E:61:67:65:72:2F:43:50:45:73:2F:67:65:6E:65:72:69:63:54:52:36:39:27:02:00:05:28:02:07:D0:2A:0E:55:54:2E:35:2E:32:2E:32:2E:31:30:35:30:33:2B:04:0A:4F:FF:0F:2C:0E:55:54:2E:35:2E:32:2E:32:2E:31:30:33:39:33:33:0C:55:54:32:00:00:00:00:00:00:00:29:08:36:01:FF:3B:0E:55:54:32:00:00:00:00:00:03:07:03:0A:00:09:3C:12:55:54:32:5F:33:2E:37:2E:33:2E:31:30:2E:39:2E:62:69:6E:3D:04:0A:4F:FF:0F:3E:3C:68:74:74:70:3A:2F:2F:31:30:2E:37:39:2E:32:35:35:2E:31:36:2F:70:75:62:2F:76:77:61:5F:69:6D:61:67:65:73:2F:76:77:61:5F:55:54:2E:35:2E:32:2E:32:2E:31:30:35:30:33:2E:74:61:72:2E:67:7A:3F:3C:68:74:74:70:3A:2F:2F:31:30:2E:37:39:2E:32:35:35:2E:31:36:2F:70:75:62:2F:76:77:61:5F:69:6D:61:67:65:73:2F:76:77:61:5F:55:54:2E:35:2E:32:2E:32:2E:31:30:33:39:33:2E:74:61:72:2E:67:7A:40:01:00})
(0)              --> 010300A0BC0209555400000000000007030E55543200000000000307030A0009041155545F332E372E332E31302E392E62696E05040A4FFF0F1444010002010311050044004407004300430101020103060701BD01BD0101020107008700880101020106C0A8640018070016001701010201031106C0A86400180700A100A11901012642687474703A2F2F6163732E6465762E636D742E7669617361742E696F3A393637352F6C6976652F4350454D616E616765722F435045732F67656E657269635452363927020005280207D02A0E55542E352E322E322E31303530332B040A4FFF0F2C0E55542E352E322E322E3130333933330C5554320000000000000029083601FF3B0E55543200000000000307030A00093C125554325F332E372E332E31302E392E62696E3D040A4FFF0F3E3C687474703A2F2F31302E37392E3235352E31362F7075622F7677615F696D616765732F7677615F55542E352E322E322E31303530332E7461722E677A3F3C687474703A2F2F31302E37392E3235352E31362F7075622F7677615F696D616765732F7677615F55542E352E322E322E31303339332E7461722E677A400100
(0)            &Tmp-String-8 := "010300A0BC0209555400000000000007030E55543200000000000307030A0009041155545F332E372E332E31302E392E62696E05040A4FFF0F1444010002010311050044004407004300430101020103060701BD01BD0101020107008700880101020106C0A8640018070016001701010201031106C0A86400180700A100A11901012642687474703A2F2F6163732E6465762E636D742E7669617361742E696F3A393637352F6C6976652F4350454D616E616765722F435045732F67656E657269635452363927020005280207D02A0E55542E352E322E322E31303530332B040A4FFF0F2C0E55542E352E322E322E3130333933330C5554320000000000000029083601FF3B0E55543200000000000307030A00093C125554325F332E372E332E31302E392E62696E3D040A4FFF0F3E3C687474703A2F2F31302E37392E3235352E31362F7075622F7677615F696D616765732F7677615F55542E352E322E322E31303530332E7461722E677A3F3C687474703A2F2F31302E37392E3235352E31362F7075622F7677615F696D616765732F7677615F55542E352E322E322E31303339332E7461722E677A400100"
...
(0)  Sending DHCP-Offer XID 1623a79a from 10.43.18.62:6767 to 10.43.18.44:6767 via eth1
(0)    DHCP-Vendor = 0x010300a0bc0209555400000000000007030e55543200000000000307030a0009041155545f332e372e332e31302e392e62696e05040a4fff0f1444010002010311050044004407004300430101020103060701bd01bd0101020107008700880101020106c0a8640018070016001701010201031106c0a86400180700a100a11901012642687474703a2f2f6163732e6465762e636d742e7669617361742e696f3a393637352f6c6976652f4350454d616e616765722f435045732f67656e657269635452363927020005280207d02a0e55542e352e322e322e31303530332b040a4fff0f2c0e55542e352e322e322e3130333933330c5554320000000000000029083601ff3b0e55543200000000000307030a00093c125554325f332e372e332e31302e392e62696e3d040a4fff0f3e3c687474703a2f2f31302e37392e3235352e31362f7075622f7677615f696d616765732f7677615f55542e352e322e322e31303530332e7461722e677a3f3c687474703a2f2f31302e37392e3235352e31362f7075622f7677615f696d616765732f7677615f55542e352e322e322e31303339332e7461722e677a400100
...

When we tried to build with the new changes, we got below error,
CC src/lib/util/regex.c
src/lib/util/regex.c:840:25: error: 'PCRE_ERROR_UNSET' undeclared here (not in a function); did you mean 'PCRE_ERROR_NULL'?
  { "PCRE_ERROR_UNSET",  PCRE_ERROR_UNSET },
                         ^~~~~~~~~~~~~~~~
                         PCRE_ERROR_NULL
make[1]: *** [build/objs/src/lib/util/regex.lo] Error 1
make[1]: *** Waiting for unfinished jobs....


Regards,
Nagamani Chinnapaiyan



More information about the Freeradius-Users mailing list