From: Alan T. DeKok Date: Tue, 12 Jan 2021 20:47:47 +0000 (-0500) Subject: ensure that the RHS is cast to the correct data type X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a19380409ca62fd8e8737e677ee3912cffaa1932;p=thirdparty%2Ffreeradius-server.git ensure that the RHS is cast to the correct data type --- diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index 273f59cdea3..1d14e1274e8 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -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;