]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
ensure that the RHS is cast to the correct data type
authorAlan T. DeKok <aland@freeradius.org>
Tue, 12 Jan 2021 20:47:47 +0000 (15:47 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 12 Jan 2021 20:49:51 +0000 (15:49 -0500)
src/lib/unlang/compile.c

index 273f59cdea38556cbf108b6aabe5ecb7c969178e..1d14e1274e88301d8b59e7a4b150ca64f6ac05b2 100644 (file)
@@ -424,7 +424,10 @@ static bool pass2_fixup_cond_map(fr_cond_t *c, CONF_ITEM *ci)
 
        if (!paircmp_find(tmpl_da(map->lhs))) return true;
 
-       if (tmpl_is_regex_xlat_unresolved(map->rhs)) {
+       /*
+        *      It's a pair comparison.  Do additional checks.
+        */
+       if (tmpl_contains_regex(map->rhs)) {
                cf_log_err(map->ci, "Cannot compare virtual attribute %s via a regex", map->lhs->name);
                return false;
        }
@@ -435,6 +438,11 @@ static bool pass2_fixup_cond_map(fr_cond_t *c, CONF_ITEM *ci)
                return false;
        }
 
+       /*
+        *      Force the RHS to be cast to whatever the LHS da is.
+        */
+       (void) tmpl_cast_set(map->rhs, tmpl_da(map->lhs)->type);
+
        if (map->op != T_OP_CMP_EQ) {
                cf_log_err(map->ci, "Must use '==' for comparisons with virtual attribute %s", map->lhs->name);
                return false;