]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
disallow "list := xlat / exec"
authorAlan T. DeKok <aland@freeradius.org>
Fri, 10 Dec 2021 19:23:49 +0000 (14:23 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 10 Dec 2021 19:25:30 +0000 (14:25 -0500)
it will likely be useful later, but for now nothing in the
code supports it

src/lib/unlang/compile.c
src/lib/unlang/edit.c

index 17741a119a609e4be52213254845ad5e869dcce6..332201ae946140e4d19e31f3b74908ae5199b316 100644 (file)
@@ -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;
+                       }
+               }
        }
 
        /*
index 3ae27bd08bba5dc1b5c60d33c59a698d1359eb14..939af22cceeab62731cd64da25049240361067fb 100644 (file)
@@ -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