]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
map_to_request expects the value callback to only create the leaf pair
authorNick Porter <nick@portercomputing.co.uk>
Tue, 29 Jul 2025 09:43:05 +0000 (10:43 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Tue, 29 Jul 2025 10:02:10 +0000 (11:02 +0100)
It does the job of creating any interim structural pairs required

src/lib/unlang/map_builtin.c
src/modules/rlm_sql/rlm_sql.c

index 97fec54e1b25fe0f6a5d2aab4e173b2fbedbb74e..1cdbbeb50be0a2e088a2961ae98069b0f6df3044 100644 (file)
@@ -48,14 +48,15 @@ static int _list_map_proc_get_value(TALLOC_CTX *ctx, fr_pair_list_t *out,
        fr_pair_t       *vp;
        fr_value_box_t  *value = talloc_get_type_abort(uctx, fr_value_box_t);
 
-       vp = fr_pair_afrom_da_nested(ctx, out, tmpl_attr_tail_da(map->lhs));
+       vp = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(map->lhs));
        if (!vp) return -1;
 
        if (fr_value_box_cast(vp, &vp->data, vp->data.type, vp->da, value) < 0) {
                RPEDEBUG("Failed casting \"%pV\" for attribute %s", value, vp->da->name);
-               fr_pair_delete(out, vp);
+               talloc_free(vp);
                return -1;
        }
+       fr_pair_append(out, vp);
 
        return 0;
 }
index b16670521bd441436f769f410a41f122485a5d55..887ff72e7b5e85e104af7f783bfa602a2740ddf1 100644 (file)
@@ -685,7 +685,7 @@ static int _sql_map_proc_get_value(TALLOC_CTX *ctx, fr_pair_list_t *out,
        fr_pair_t       *vp;
        char const      *value = uctx;
 
-       vp = fr_pair_afrom_da_nested(ctx, out, tmpl_attr_tail_da(map->lhs));
+       vp = fr_pair_afrom_da(ctx, tmpl_attr_tail_da(map->lhs));
        if (!vp) return -1;
 
        /*
@@ -695,9 +695,10 @@ static int _sql_map_proc_get_value(TALLOC_CTX *ctx, fr_pair_list_t *out,
        if (fr_pair_value_from_str(vp, value, strlen(value), NULL, true) < 0) {
                RPEDEBUG("Failed parsing value \"%pV\" for attribute %s",
                         fr_box_strvalue_buffer(value), vp->da->name);
-               fr_pair_delete(out, vp);
+               talloc_free(vp);
                return -1;
        }
+       fr_pair_append(out, vp);
 
        return 0;
 }