From: Nick Porter Date: Thu, 6 Jul 2023 12:02:56 +0000 (+0100) Subject: Return correctly after first match for logical or X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de150f3aa1c38ab7864bf17d78d2066a5d428b75;p=thirdparty%2Ffreeradius-server.git Return correctly after first match for logical or --- diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index 4371d9b32b4..3661c7804d9 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -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++; /*