From: Alan T. DeKok Date: Tue, 27 Apr 2021 13:15:24 +0000 (-0400) Subject: move regex sanity checks to map_afrom_substr() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dca3ed060136fc73342f8d161563b7e9ba169bad;p=thirdparty%2Ffreeradius-server.git move regex sanity checks to map_afrom_substr() --- diff --git a/src/lib/server/map.c b/src/lib/server/map.c index f1ec2c78b32..3530aa5290c 100644 --- a/src/lib/server/map.c +++ b/src/lib/server/map.c @@ -438,6 +438,26 @@ ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, fr_sbuff_t *in, } } + if (tmpl_contains_regex(map->lhs)) { + fr_sbuff_set(&our_in, &m_lhs); + fr_strerror_const("Unexpected regular expression"); + goto error; + } + + if ((map->op == T_OP_REG_EQ) || (map->op == T_OP_REG_NE)) { + if (!tmpl_contains_regex(map->rhs)) { + fr_sbuff_set(&our_in, &m_rhs); + fr_strerror_const("Expected regular expression after regex operator"); + goto error; + } + } else { + if (tmpl_contains_regex(map->rhs)) { + fr_sbuff_set(&our_in, &m_rhs); + fr_strerror_const("Unexpected regular expression"); + goto error; + } + } + MAP_VERIFY(map); *out = map; diff --git a/src/lib/server/users_file.c b/src/lib/server/users_file.c index bf20496e452..9699e835ec8 100644 --- a/src/lib/server/users_file.c +++ b/src/lib/server/users_file.c @@ -442,13 +442,6 @@ check_item: } if (tmpl_contains_regex(new_map->rhs)) { - if (!((new_map->op == T_OP_REG_EQ) || - (new_map->op == T_OP_REG_NE))) { - ERROR("%s[%d]: Unexpected regular expression on RHS of check item", - file, line); - goto fail_entry; - } - /* * The default rules say that the check * items look at the control list, but