From: Alan T. DeKok Date: Fri, 21 May 2021 13:27:13 +0000 (-0400) Subject: hoist T_OP_CMP_TRUE checks to earlier in the process X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf2ae5dcc436c2a0725260e6bb1ec8e8f8de8a02;p=thirdparty%2Ffreeradius-server.git hoist T_OP_CMP_TRUE checks to earlier in the process --- diff --git a/src/lib/server/map.c b/src/lib/server/map.c index fde2a567159..9948a119393 100644 --- a/src/lib/server/map.c +++ b/src/lib/server/map.c @@ -960,6 +960,16 @@ int map_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t co */ if (map->op == T_OP_CMP_FALSE) return 0; + /* + * Hoist this early, too. + */ + if (map->op == T_OP_CMP_TRUE) { + MEM(n = fr_pair_afrom_da(ctx, tmpl_da(map->lhs))); + n->op = map->op; + fr_pair_append(out, n); + return 0; + } + /* * List to list found, this is a special case because we don't need * to allocate any attributes, just finding the current list, and change @@ -1112,13 +1122,12 @@ int map_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t co talloc_free(n); goto error; } - } else if (map->op != T_OP_CMP_TRUE) { - if (fr_value_box_cast(n, &n->data, n->vp_type, n->da, tmpl_value(map->rhs)) < 0) { - RPEDEBUG("Implicit cast failed"); - rcode = -1; - talloc_free(n); - goto error; - } + + } else if (fr_value_box_cast(n, &n->data, n->vp_type, n->da, tmpl_value(map->rhs)) < 0) { + RPEDEBUG("Implicit cast failed"); + rcode = -1; + talloc_free(n); + goto error; } n->op = map->op; fr_pair_append(out, n);