]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix a large number of invalid ctx uses in fr_value_box* functions
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 3 Sep 2023 17:09:28 +0000 (11:09 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 3 Sep 2023 17:11:14 +0000 (11:11 -0600)
16 files changed:
src/lib/eap_aka_sim/xlat.c
src/lib/json/json.c
src/lib/ldap/util.c
src/lib/redis/redis.c
src/lib/server/main_config.c
src/lib/server/tmpl_eval.c
src/lib/server/trigger.c
src/lib/unlang/edit.c
src/lib/unlang/foreach.c
src/lib/unlang/xlat_builtin.c
src/lib/unlang/xlat_eval.c
src/modules/rlm_cache/rlm_cache.c
src/modules/rlm_dict/rlm_dict.c
src/modules/rlm_ldap/rlm_ldap.c
src/modules/rlm_perl/rlm_perl.c
src/modules/rlm_test/rlm_test.c

index 9c04c222d6e35b3fe271035eb2cdd3209812ea85..1805a8f34cf25c2056ffc0198abe49d43bc8f34f 100644 (file)
@@ -140,7 +140,7 @@ static xlat_action_t aka_sim_xlat_id_type_xlat(TALLOC_CTX *ctx, fr_dcursor_t *ou
        }
 
        MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_STRING, NULL));
-       fr_value_box_bstrndup(ctx, vb, NULL, type, strlen(type), false);
+       fr_value_box_bstrndup(vb, vb, NULL, type, strlen(type), false);
        fr_dcursor_append(out, vb);
 
        return XLAT_ACTION_DONE;
@@ -490,7 +490,7 @@ static xlat_action_t aka_sim_3gpp_temporary_id_encrypt_xlat(TALLOC_CTX *ctx, fr_
        }
 
        MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_STRING, NULL));
-       fr_value_box_bstrndup(ctx, vb, NULL, encrypted, strlen(encrypted), false);
+       fr_value_box_bstrndup(vb, vb, NULL, encrypted, strlen(encrypted), false);
        fr_dcursor_append(out, vb);
 
        return XLAT_ACTION_DONE;
index 222aff3c33bd46afb351b6b16ccaa639f5a1cdc2..46b67ba264adc37b8fe892aee3998f5cd34589b9 100644 (file)
@@ -125,7 +125,7 @@ int fr_json_object_to_value_box(TALLOC_CTX *ctx, fr_value_box_t *out, json_objec
                /*
                 *      Just copy the string to the box.
                 */
-               fr_value_box_bstrndup(ctx, out, NULL, value, len, tainted);
+               fr_value_box_bstrndup(out, out, NULL, value, len, tainted);
        }
                break;
 
@@ -178,7 +178,7 @@ int fr_json_object_to_value_box(TALLOC_CTX *ctx, fr_value_box_t *out, json_objec
        {
                char const *value = json_object_to_json_string(object);
 
-               fr_value_box_bstrndup(ctx, out, NULL, value, strlen(value), tainted);
+               fr_value_box_bstrndup(out, out, NULL, value, strlen(value), tainted);
        }
                break;
        }
index a6e1531b77ab3fca5d50139d141c2f3ae01f3e55..1f16b141c989693829feb908c69a0461420ca9f1 100644 (file)
@@ -69,7 +69,6 @@ static const bool escapes[UINT8_MAX + 1] = {
  */
 size_t fr_ldap_escape_func(UNUSED request_t *request, char *out, size_t outlen, char const *in, UNUSED void *arg)
 {
-
        size_t left = outlen;
 
        if (*in && ((*in == ' ') || (*in == '#'))) goto encode;
index 47b6a6f7ef5fc882c82c2253f4e7064b84d40b84..99ad53042dd047c82f05b7d4ee78bd1000a163b3 100644 (file)
@@ -281,7 +281,7 @@ int fr_redis_reply_to_value_box(TALLOC_CTX *ctx, fr_value_box_t *out, redisReply
                if (shallow) {
                        fr_value_box_bstrndup_shallow(to_cast, NULL, reply->str, reply->len, true);
                } else {
-                       if (fr_value_box_bstrndup(ctx, to_cast, NULL, reply->str, reply->len, true) < 0) return -1;
+                       if (fr_value_box_bstrndup(to_cast, to_cast, NULL, reply->str, reply->len, true) < 0) return -1;
                }
                break;
 
@@ -297,7 +297,7 @@ int fr_redis_reply_to_value_box(TALLOC_CTX *ctx, fr_value_box_t *out, redisReply
                        fr_strerror_const("Out of memory");
                        return -1;
                }
-               if (fr_value_box_bstrndup(ctx, verb, NULL, reply->str, reply->len, true) < 0) return -1;
+               if (fr_value_box_bstrndup(verb, verb, NULL, reply->str, reply->len, true) < 0) return -1;
                fr_value_box_list_insert_head(&out->vb_group, verb);
 
                vtype = fr_value_box_alloc(ctx, FR_TYPE_STRING, NULL);
index c0961e73f46b841b9e89b25714e82a2869cba715..eafc60bce604cad77621ad43eb1a770b30bfbe8c 100644 (file)
@@ -576,7 +576,7 @@ static xlat_action_t xlat_config(TALLOC_CTX *ctx, fr_dcursor_t *out,
        if (!value) return XLAT_ACTION_DONE;
 
        MEM(vb = fr_value_box_alloc_null(ctx));
-       fr_value_box_bstrndup(ctx, vb, NULL, value, strlen(value), false);
+       fr_value_box_bstrndup(vb, vb, NULL, value, strlen(value), false);
        fr_dcursor_append(out, vb);
 
        return XLAT_ACTION_DONE;
index 90eca0de5d0ce1353c91a6ac6970f472e26741d1..86586953439a97b4b2f14c8081df9fae0511e395 100644 (file)
@@ -723,7 +723,7 @@ ssize_t _tmpl_to_atype(TALLOC_CTX *ctx, void *out,
 
                MEM(*vb_out = fr_value_box_alloc_null(ctx));
 
-               ret = needs_dup ? fr_value_box_copy(ctx, *vb_out, to_cast) : fr_value_box_steal(ctx, *vb_out, to_cast);
+               ret = needs_dup ? fr_value_box_copy(*vb_out, *vb_out, to_cast) : fr_value_box_steal(*vb_out, *vb_out, to_cast);
                talloc_free(tmp_ctx);
                if (ret < 0) {
                        RPEDEBUG("Failed copying data to output box");
index 229ff8ea8806dd5baed46149c1405f9c9332021c..862f18d069b0dcdff7b832c358eaf8b7141bb4de 100644 (file)
@@ -97,7 +97,7 @@ xlat_action_t trigger_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
        }
 
        MEM(vb = fr_value_box_alloc_null(ctx));
-       fr_value_box_copy(ctx, vb, &vp->data);
+       fr_value_box_copy(vb, vb, &vp->data);
        fr_dcursor_append(out, vb);
        return XLAT_ACTION_DONE;
 }
index 38be510931f9e413b77fd649feab2972d955f430..91086559b337b02bfc86413df4567935ea1fca67 100644 (file)
@@ -1074,7 +1074,7 @@ static int check_lhs_value(request_t *request, unlang_frame_state_edit_t *state,
 
        data:
                MEM(box = fr_value_box_alloc_null(state));
-               if (fr_value_box_copy(state, box, tmpl_value(vpt)) < 0) return -1;
+               if (fr_value_box_copy(box, box, tmpl_value(vpt)) < 0) return -1;
 
                fr_value_box_list_insert_tail(&current->parent->rhs.result, box);
 
@@ -1098,7 +1098,7 @@ static int check_lhs_value(request_t *request, unlang_frame_state_edit_t *state,
                vp = tmpl_dcursor_init(NULL, request, &cc, &cursor, request, vpt);
                while (vp) {
                        MEM(box = fr_value_box_alloc_null(state));
-                       if (fr_value_box_copy(state, box, &vp->data) < 0) return -1;
+                       if (fr_value_box_copy(box, box, &vp->data) < 0) return -1;
 
                        fr_value_box_list_insert_tail(&current->parent->rhs.result, box);
 
index 10ada1dfef3969ec2981d8b9aa02795cc9dfa520..15630b79db60fbde4c51f3eac01590295cf338ea 100644 (file)
@@ -263,7 +263,7 @@ static xlat_action_t unlang_foreach_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
        fr_assert(vp != NULL);
 
        MEM(vb = fr_value_box_alloc_null(ctx));
-       fr_value_box_copy(ctx, vb, &vp->data);
+       fr_value_box_copy(vb, vb, &vp->data);
        fr_dcursor_append(out, vb);
        return XLAT_ACTION_DONE;
 }
index a4384d46d7cca8ad634cf920dfa597961a26cfb0..3e04906634a2a5c9420e75116fd3662526028127 100644 (file)
@@ -512,7 +512,7 @@ static xlat_action_t xlat_func_explode(TALLOC_CTX *ctx, fr_dcursor_t *out,
                                if (fr_sbuff_behind(&m_start) == 0) goto advance;
 
                                MEM(vb = fr_value_box_alloc_null(ctx));
-                               fr_value_box_bstrndup(ctx, vb, NULL, fr_sbuff_current(&m_start),
+                               fr_value_box_bstrndup(vb, vb, NULL, fr_sbuff_current(&m_start),
                                                      fr_sbuff_behind(&m_start), string->tainted);
                                fr_dcursor_append(out, vb);
 
@@ -523,7 +523,7 @@ static xlat_action_t xlat_func_explode(TALLOC_CTX *ctx, fr_dcursor_t *out,
                        }
                        fr_sbuff_set_to_end(&sbuff);
                        MEM(vb = fr_value_box_alloc_null(ctx));
-                       fr_value_box_bstrndup(ctx, vb, NULL, fr_sbuff_current(&m_start),
+                       fr_value_box_bstrndup(vb, vb, NULL, fr_sbuff_current(&m_start),
                                              fr_sbuff_behind(&m_start), string->tainted);
                        fr_dcursor_append(out, vb);
                        break;
@@ -709,7 +709,7 @@ static xlat_action_t xlat_func_integer(TALLOC_CTX *ctx, fr_dcursor_t *out,
                fr_snprint_uint128(buff, sizeof(buff), ntohlll(ipv6int));
 
                MEM(vb = fr_value_box_alloc_null(ctx));
-               fr_value_box_bstrndup(ctx, vb, NULL, buff, strlen(buff), false);
+               fr_value_box_bstrndup(vb, vb, NULL, buff, strlen(buff), false);
                fr_dcursor_append(out, vb);
                talloc_free(in_vb);
                return XLAT_ACTION_DONE;
index e9b0d9ddb953e01f0e6d02837ca4a530f97cbb23..9dc83597f7a07d68998d1c06a24bb6fc5555e0f1 100644 (file)
@@ -1149,7 +1149,7 @@ xlat_action_t xlat_frame_eval(TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_exp_head_
                         *      because references aren't threadsafe.
                         */
                        MEM(value = fr_value_box_alloc_null(ctx));
-                       if (fr_value_box_copy(ctx, value, &node->data) < 0) goto fail;
+                       if (fr_value_box_copy(value, value, &node->data) < 0) goto fail;
                        fr_dcursor_append(out, value);
                        continue;
 
index efdf9b81790f60975e97feb4092e8bc83659a6dc..364281174f56a9ce92d6fd39bbc3227220b98221 100644 (file)
@@ -872,7 +872,7 @@ xlat_action_t cache_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
                    (tmpl_list(map->lhs) != tmpl_list(target))) continue;
 
                MEM(vb = fr_value_box_alloc_null(ctx));
-               fr_value_box_copy(ctx, vb, tmpl_value(map->rhs));
+               fr_value_box_copy(vb, vb, tmpl_value(map->rhs));
                fr_dcursor_append(out, vb);
                break;
        }
index 2e8c8bd6293eb61f1f1ceb252cd53f9053666929..49d82dd8797ef864b2e508e8d0bbe11fb529b0e3 100644 (file)
@@ -53,7 +53,7 @@ static xlat_action_t xlat_dict_attr_by_num(TALLOC_CTX *ctx, fr_dcursor_t *out,
 
        MEM(vb = fr_value_box_alloc_null(ctx));
 
-       if (fr_value_box_bstrndup(ctx, vb, NULL, da->name, strlen(da->name), false) < 0) {
+       if (fr_value_box_bstrndup(vb, vb, NULL, da->name, strlen(da->name), false) < 0) {
                talloc_free(vb);
                return XLAT_ACTION_FAIL;
        }
@@ -92,7 +92,7 @@ static xlat_action_t xlat_dict_attr_by_oid(TALLOC_CTX *ctx, fr_dcursor_t *out,
 
        MEM(vb = fr_value_box_alloc_null(ctx));
 
-       if (fr_value_box_bstrndup(ctx, vb, NULL, da->name, strlen(da->name), false) < 0) {
+       if (fr_value_box_bstrndup(vb, vb, NULL, da->name, strlen(da->name), false) < 0) {
                talloc_free(vb);
                return XLAT_ACTION_FAIL;
        }
@@ -126,7 +126,7 @@ static xlat_action_t xlat_vendor(TALLOC_CTX *ctx, fr_dcursor_t *out,
 
        MEM(vb = fr_value_box_alloc_null(ctx));
 
-       if (fr_value_box_bstrndup(ctx, vb, NULL, vendor->name, strlen(vendor->name), false) < 0) {
+       if (fr_value_box_bstrndup(vb, vb, NULL, vendor->name, strlen(vendor->name), false) < 0) {
                talloc_free(vb);
                return XLAT_ACTION_FAIL;
        }
@@ -181,7 +181,7 @@ static xlat_action_t xlat_attr(TALLOC_CTX *ctx, fr_dcursor_t *out,
 
        MEM(vb = fr_value_box_alloc_null(ctx));
 
-       if (fr_value_box_bstrndup(ctx, vb, NULL, vp->da->name, strlen(vp->da->name), false) < 0) {
+       if (fr_value_box_bstrndup(vb, vb, NULL, vp->da->name, strlen(vp->da->name), false) < 0) {
                talloc_free(vb);
                return XLAT_ACTION_FAIL;
        }
index 343563f114bde65ad731b73750ddc12559651040..202ecd902f12dfc93efa947513e0717071694180 100644 (file)
@@ -515,7 +515,7 @@ static xlat_action_t ldap_xlat_resume(TALLOC_CTX *ctx, fr_dcursor_t *out,
                        count = ldap_count_values_len(values);
                        for (i = 0; i < count; i++) {
                                MEM(vb = fr_value_box_alloc_null(ctx));
-                               if (fr_value_box_bstrndup(ctx, vb, NULL, values[i]->bv_val, values[i]->bv_len, true) < 0) {
+                               if (fr_value_box_bstrndup(vb, vb, NULL, values[i]->bv_val, values[i]->bv_len, true) < 0) {
                                        talloc_free(vb);
                                        RPERROR("Failed creating value from LDAP response");
                                        break;
index 4760b4d4a886b3d4c63e23a653b8ea392bb1f15b..1c344ea722095a58b8e4017a067bfd7128e04dc8 100644 (file)
@@ -343,7 +343,7 @@ static int perl_sv_to_vblist(TALLOC_CTX *ctx, fr_value_box_list_t *list, request
                DEBUG3("String returned");
                tmp = SvPVutf8(sv, len);
                MEM(vb = fr_value_box_alloc_null(ctx));
-               if (fr_value_box_bstrndup(ctx, vb, NULL, tmp, len, SvTAINTED(sv)) < 0) {
+               if (fr_value_box_bstrndup(vb, vb, NULL, tmp, len, SvTAINTED(sv)) < 0) {
                        talloc_free(vb);
                        RPEDEBUG("Failed to allocate %ld for output", len);
                        return -1;
@@ -378,7 +378,7 @@ static int perl_sv_to_vblist(TALLOC_CTX *ctx, fr_value_box_list_t *list, request
                         *      Add key first
                         */
                        MEM(vb = fr_value_box_alloc_null(ctx));
-                       if (fr_value_box_bstrndup(ctx, vb, NULL, tmp, sv_len, SvTAINTED(hv_sv)) < 0) {
+                       if (fr_value_box_bstrndup(vb, vb, NULL, tmp, sv_len, SvTAINTED(hv_sv)) < 0) {
                                talloc_free(vb);
                                RPEDEBUG("Failed to allocate %d for output", sv_len);
                                return -1;
index 49c7042258bf53e7b6e18d2259f4c074487f713f..c93d97723e5fd17dc19d245f188e43e824886952 100644 (file)
@@ -389,7 +389,7 @@ static xlat_action_t test_xlat_passthrough(TALLOC_CTX *ctx, fr_dcursor_t *out,
        fr_value_box_list_foreach(in, vb_p) {
                MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_STRING, NULL));
 
-               if (fr_value_box_copy(ctx, vb, vb_p) < 0) {
+               if (fr_value_box_copy(vb, vb, vb_p) < 0) {
                        talloc_free(vb);
                        return XLAT_ACTION_FAIL;
                }