]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Return correctly after first match for logical or
authorNick Porter <nick@portercomputing.co.uk>
Thu, 6 Jul 2023 12:02:56 +0000 (13:02 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Thu, 6 Jul 2023 13:05:05 +0000 (14:05 +0100)
src/lib/unlang/xlat_expr.c

index 4371d9b32b4aeb88b8dd99c396a6484f24eb4cd3..3661c7804d9e0230e665f743eddea126b29711d7 100644 (file)
@@ -1192,6 +1192,7 @@ static xlat_action_t xlat_logical_resume(TALLOC_CTX *ctx, fr_dcursor_t *out,
 {
        xlat_logical_inst_t const *inst = talloc_get_type_abort_const(xctx->inst, xlat_logical_inst_t);
        xlat_logical_rctx_t     *rctx = talloc_get_type_abort(xctx->rctx, xlat_logical_rctx_t);
+       bool                    match;
 
        /*
         *      If one of the expansions fails, then we fail the
@@ -1208,7 +1209,8 @@ static xlat_action_t xlat_logical_resume(TALLOC_CTX *ctx, fr_dcursor_t *out,
         *
         *      (a, b, c) || (d, e, f) == a || b || c || d || e || f
         */
-       if (!xlat_logical_match(&rctx->box, &rctx->list, inst->stop_on_match)) {
+       match = xlat_logical_match(&rctx->box, &rctx->list, inst->stop_on_match);
+       if (!match) {
                /*
                 *      If nothing matches, we return a "false" box.
                 */
@@ -1225,6 +1227,12 @@ static xlat_action_t xlat_logical_resume(TALLOC_CTX *ctx, fr_dcursor_t *out,
        }
 
        fr_value_box_list_talloc_free(&rctx->list);
+
+       /*
+        *      If we stop on the first match, and we got a "true" match we're done.
+        */
+       if (inst->stop_on_match && match && fr_value_box_is_truthy(rctx->box)) goto done;
+
        rctx->current++;
 
        /*