]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move regex comparisons to calc.c code
authorAlan T. DeKok <aland@freeradius.org>
Mon, 18 Dec 2023 22:28:33 +0000 (17:28 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 18 Dec 2023 22:28:47 +0000 (17:28 -0500)
src/lib/server/pairmove.c
src/lib/util/calc.c

index ba1e5ca012927d21f59ca8675ddbe2233577a8f2..9675ac5eaf63201f014f154cc3394c029541a3c4 100644 (file)
@@ -482,24 +482,6 @@ int radius_legacy_map_cmp(request_t *request, map_t const *map)
                return -1;
        }
 
-       /*
-        *      The RHS is a compiled regex, which we don't yet
-        *      support.  So just re-parse it at run time for
-        *      programmer laziness.
-        */
-       if ((map->op == T_OP_REG_EQ) || (map->op == T_OP_REG_NE)) {
-               if (box->type != FR_TYPE_STRING) {
-                       fr_strerror_const("Invalid type for regular expression");
-                       return -1;
-               }
-
-               rcode = fr_regex_cmp_op(map->op, &vp->data, box);
-               TALLOC_FREE(to_free);
-               if (rcode < 0) return rcode;
-
-               return (rcode == 1);
-       }
-
        /*
         *      Let the calculation code do upcasting as necessary.
         */
index bfd8be60a5f6ac18262604b73bb6be6ca9fe08a1..948d617c8625dec9e0031fbe2c24c84a7f3e71a1 100644 (file)
@@ -26,6 +26,7 @@
 RCSID("$Id$")
 
 #include <freeradius-devel/util/strerror.h>
+#include <freeradius-devel/util/regex.h>
 #include <math.h>
 #include "calc.h"
 
@@ -1934,6 +1935,20 @@ int fr_value_calc_binary_op(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t hint
                op = T_OP_NE;
                break;
 
+       case T_OP_REG_EQ:
+       case T_OP_REG_NE:
+               if (b->type != FR_TYPE_STRING) {
+                       fr_strerror_const("Invalid type for regular expression");
+                       return -1;
+               }
+
+               rcode = fr_regex_cmp_op(op, a, b);
+               if (rcode < 0) return rcode;
+
+               fr_value_box_init(dst, FR_TYPE_BOOL, NULL, false); /* @todo - enum */
+               dst->vb_bool = (rcode != 0);
+               return 0;
+
        default:
                break;
        }