From: Alan T. DeKok Date: Fri, 10 Dec 2021 19:23:49 +0000 (-0500) Subject: disallow "list := xlat / exec" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e2617ac99c8717043323af35c9dbbb7c3c4ee28;p=thirdparty%2Ffreeradius-server.git disallow "list := xlat / exec" it will likely be useful later, but for now nothing in the code supports it --- diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index 17741a119a6..332201ae946 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -586,6 +586,18 @@ static bool pass2_fixup_map(map_t *map, tmpl_rules_t const *rules, fr_dict_attr_ return false; } } + + /* + * If the LHS is structural, then that limits + * what the RHS can be. + */ + if (tmpl_is_list(map->lhs) || + (tmpl_is_attr(map->lhs) && fr_type_is_structural(tmpl_da(map->lhs)->type))) { + if (!tmpl_is_list(map->rhs) && !tmpl_is_attr(map->rhs)) { + cf_log_err(map->ci, "Cannot assign xlat / data / exec to list or structural type"); + return false; + } + } } /* diff --git a/src/lib/unlang/edit.c b/src/lib/unlang/edit.c index 3ae27bd08bb..939af22ccee 100644 --- a/src/lib/unlang/edit.c +++ b/src/lib/unlang/edit.c @@ -111,7 +111,10 @@ static int templatize_rhs(TALLOC_CTX *ctx, edit_result_t *out, fr_pair_t const * bool is_string; fr_value_box_t *box = fr_dlist_head(&out->result); - fr_assert(fr_type_is_leaf(lhs->vp_type)); + if (!fr_type_is_leaf(lhs->vp_type)) { + REDEBUG("RHS is not a leaf"); + return -1; + } /* * There's only one box, and it's the correct type. Just