From: Alan T. DeKok Date: Wed, 16 Nov 2022 18:02:40 +0000 (-0500) Subject: forbid array references in sublists X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=deefad1ef60f9298ae1e764ab3dd4b05e92022fa;p=thirdparty%2Ffreeradius-server.git forbid array references in sublists &list := { &foo[1] = "bar" } The edit code does not support this, because it doesn't really make a lot of sense. If we do need to support it, then the edit code needs to be updated to support it. Note that we can already do &list.foo[1] = "bar" so this limitation isn't much of an issue. The problem comes when doing multiple attribute assignments, and those using array indexes inside of a sublist. What does it mean when we do &list := { &foo[0] = "bar" &foo[1] = "baz" &foo[0] = "ugh" } What the heck is going on here? The real answer is "don't do that" --- diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index e99ec0c4eec..57a417502eb 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -1820,9 +1820,23 @@ static unlang_t *compile_edit_section(unlang_t *parent, unlang_compile_t *unlang */ parent_da = tmpl_da(map->lhs); if (fr_type_is_structural(parent_da->type)) { + map_t *child; + if (map_afrom_cs(map, &map->child, cs, &t_rules, &t_rules, unlang_fixup_edit, map, 256) < 0) { goto fail; } + + /* + * As a set of fixups... we can't do array references in -= + */ + for (child = map_list_head(&map->child); child != NULL; child = map_list_next(&map->child, child)) { + if (!tmpl_is_attr(child->lhs)) continue; + + if (tmpl_num(child->lhs) != NUM_UNSPEC) { + cf_log_err(child->ci, "Cannot use array references and values when deleting from a list"); + goto fail; + } + } } else { /* * &foo := { a, b, c }