From: Alan T. DeKok Date: Sun, 31 Jul 2022 01:17:36 +0000 (-0400) Subject: use comparison operators for RHS list of &request -= { ... } X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6526e0dfc3dd88a9df3285b803a8eed0318ee33f;p=thirdparty%2Ffreeradius-server.git use comparison operators for RHS list of &request -= { ... } --- diff --git a/src/lib/unlang/edit.c b/src/lib/unlang/edit.c index a10734d2726..0e929d58097 100644 --- a/src/lib/unlang/edit.c +++ b/src/lib/unlang/edit.c @@ -780,7 +780,7 @@ redo: * Child attributes are created in a temporary list. Any list editing is * taken care of by the parent map. */ - fr_assert(map->op == T_OP_EQ); + fr_assert((map->op == T_OP_EQ) || (current->parent->map->op == T_OP_SUB_EQ)); /* * We create this VP in the "current" context, so that it's freed on @@ -792,6 +792,7 @@ redo: */ MEM(current->lhs.vp = fr_pair_afrom_da(current, tmpl_da(current->lhs.vpt))); fr_pair_append(¤t->parent->rhs.pair_list, current->lhs.vp); + current->lhs.vp->op = map->op; current->in_parent_list = true; } else if (tmpl_find_vp(¤t->lhs.vp, request, current->lhs.vpt) < 0) { diff --git a/src/lib/util/edit.c b/src/lib/util/edit.c index 9d9788ffdbe..1d1dd02200c 100644 --- a/src/lib/util/edit.c +++ b/src/lib/util/edit.c @@ -817,8 +817,10 @@ static int fr_edit_list_delete_list(fr_edit_list_t *el, fr_pair_list_t *list, fr found = fr_pair_find_by_da(list, found, vp->da)) { int rcode; - rcode = fr_value_box_cmp(&vp->data, &found->data); - if (rcode != 0) continue; + rcode = fr_value_box_cmp_op(vp->op, &vp->data, &found->data); + if (rcode < 0) return -1; + + if (!rcode) continue; if (fr_edit_list_pair_delete(el, list, found) < 0) return -1; break; diff --git a/src/tests/keywords/edit-list-remove b/src/tests/keywords/edit-list-remove index a90140b72ff..db29caed26a 100644 --- a/src/tests/keywords/edit-list-remove +++ b/src/tests/keywords/edit-list-remove @@ -75,7 +75,7 @@ if (&request.Tmp-String-0) { # as a condition? For now, it's an exact match. :( # &request -= { - &Tmp-String-0 = "bar" + &Tmp-String-0 == "bar" } if (&Tmp-String-0[0] != "foo") {