]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Move vb size field into a struct with the ptr types in fr_value_box_t
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 14 Dec 2022 23:46:29 +0000 (17:46 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 14 Dec 2022 23:46:29 +0000 (17:46 -0600)
Print some extra size information in radsize

14 files changed:
src/lib/ldap/filter.c
src/lib/server/map_async.c
src/lib/unlang/edit.c
src/lib/util/calc.c
src/lib/util/uri.c
src/listen/ldap_sync/proto_ldap_sync.c
src/modules/rlm_escape/rlm_escape.c
src/modules/rlm_ldap/rlm_ldap.c
src/modules/rlm_mschap/rlm_mschap.c
src/modules/rlm_perl/rlm_perl.c
src/modules/rlm_rest/rlm_rest.c
src/modules/rlm_sql/rlm_sql.c
src/modules/rlm_unbound/rlm_unbound.c
src/modules/rlm_unpack/rlm_unpack.c

index 57e50236f39e94f55f57896c0462d4f5c3616c13..c22f401ad06cda019cb43ff8731482669799fdfd 100644 (file)
@@ -445,7 +445,7 @@ static bool ldap_filter_node_eval(ldap_filter_t *node, fr_ldap_connection_t *con
                case LDAP_FILTER_OP_EQ:
                        for (i = 0; i < count; i++) {
                                DEBUG_LDAP_ATTR_VAL
-                               if ((node->value->length == values[i]->bv_len) &&
+                               if ((node->value->vb_length == values[i]->bv_len) &&
                                    (strncasecmp(values[i]->bv_val, node->value->vb_strvalue, values[i]->bv_len) == 0)) {
                                        filter_state = true;
                                        break;
@@ -466,7 +466,7 @@ static bool ldap_filter_node_eval(ldap_filter_t *node, fr_ldap_connection_t *con
                         *      Point t_end at the final character of the filter value
                         *      - not the NULL - so we can check for trailing '*'
                         */
-                       t_end = node->value->vb_strvalue + node->value->length - 1;
+                       t_end = node->value->vb_strvalue + node->value->vb_length - 1;
 
                        for (i = 0; i < count; i++) {
                                DEBUG_LDAP_ATTR_VAL
index 8ed1ef6842d171a11aca41dc83bbd0175c682fa9..fdb905e65e9718faa2903876467e10ff5cb230f0 100644 (file)
@@ -158,13 +158,7 @@ static inline vp_list_mod_t *list_mod_empty_string_afrom_map(TALLOC_CTX *ctx,
 {
        vp_list_mod_t           *n;
        map_t                   *mod;
-       fr_value_box_t          empty_string = {
-                                       .type = FR_TYPE_STRING,
-                                       .datum = {
-                                               .strvalue = "",
-                                       },
-                                       .length = 0,
-                               };
+       fr_value_box_t          empty_string = *fr_box_strvalue_len("", 0);
 
        n = list_mod_alloc(ctx);
        if (!n) return NULL;
index b1c820de45ac635cd17d72e4b09a4a338595ab19..f7b783e673476564526e0ff397622b3a2f87f71e 100644 (file)
@@ -286,7 +286,7 @@ static int apply_edits_to_list(request_t *request, unlang_frame_state_edit_t *st
                 *      parent VP.  Because we're going to be moving them to the parent VP at some
                 *      point.  The ones which aren't moved will get deleted in this function.
                 */
-               token = fr_pair_list_afrom_str(state, da, box->vb_strvalue, box->length, children);
+               token = fr_pair_list_afrom_str(state, da, box->vb_strvalue, box->vb_length, children);
                if (token == T_INVALID) {
                        RPEDEBUG("Failed parsing string '%pV' as attribute list", box);
                        return -1;
index 63badf72533f73bc1a53f4c691042e52e90ea2e4..2d13341677e28ebbbc86970bdad647851c9362b1 100644 (file)
@@ -845,7 +845,7 @@ static int calc_octets(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t cons
                COERCE_B(FR_TYPE_OCTETS, dst->enumv);
        }
 
-       len = a->length + b->length;
+       len = a->vb_length + b->vb_length;
 
        switch (op) {
        case T_ADD:     /* dst = a . b */
@@ -985,7 +985,7 @@ static int calc_string(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t cons
                COERCE_B(FR_TYPE_STRING, dst->enumv);
        }
 
-       len = a->length + b->length;
+       len = a->vb_length + b->vb_length;
 
        switch (op) {
        case T_ADD:
index 3a711586fbf481202faf5c7eb19c6caf851ed455..2e4fabb58b5969eefb07dde6e8cc12b0ef9aa8f1 100644 (file)
@@ -81,12 +81,12 @@ int fr_uri_escape(FR_DLIST_HEAD(fr_value_box_list) *uri, fr_uri_part_t const *ur
                /*
                 *      Zero length box - no terminators here
                 */
-               if (uri_vb->length == 0) continue;
+               if (uri_vb->vb_length == 0) continue;
 
                /*
                 *      Look for URI part terminator
                 */
-               fr_sbuff_init_in(&sbuff, uri_vb->vb_strvalue, uri_vb->length);
+               fr_sbuff_init_in(&sbuff, uri_vb->vb_strvalue, uri_vb->vb_length);
 
                do {
                        fr_sbuff_adv_until(&sbuff, SIZE_MAX, uri_part->terminals, '\0');
index da71041596b8a83dd6e4a54c93bdf9546908c3e7..2d456057f4871f40e77844f6e976368770fef829 100644 (file)
@@ -222,7 +222,7 @@ static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8
        if ((request->rcode != RLM_MODULE_OK) && (request->rcode != RLM_MODULE_UPDATED)) goto send;
 
        vp = fr_pair_find_by_da_nested(&request->reply_pairs, NULL, attr_ldap_sync_cookie);
-       if ((vp) && (vp->data.length > 0)) {
+       if ((vp) && (vp->data.vb_length > 0)) {
                fr_pair_remove(&request->reply_pairs, vp);
                fr_pair_steal_append(local, &pairs, vp);
        }
index 829ccb89a7958344e523ee42cb05d63f33dcc4d0..e1919531f6bed9c31433fc07d47921e8b041f685 100644 (file)
@@ -78,7 +78,7 @@ static xlat_action_t escape_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
         *      as a starting point.  The maximum length would be 12
         *      times the original if every character is 4 byte UTF8.
         */
-       if (!fr_sbuff_init_talloc(vb, &sbuff, &sbuff_ctx, arg->length * 2, arg->length * 12)) {
+       if (!fr_sbuff_init_talloc(vb, &sbuff, &sbuff_ctx, arg->vb_length * 2, arg->vb_length * 12)) {
        error:
                RPEDEBUG("Failed to allocated buffer for escaped string");
                talloc_free(vb);
@@ -139,15 +139,15 @@ static xlat_action_t unescape_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
        fr_value_box_t  *vb;
 
        MEM(vb = fr_value_box_alloc_null(ctx));
-       if (fr_value_box_bstr_alloc(ctx, &out_p, vb, NULL, arg->length, arg->tainted) < 0) {
+       if (fr_value_box_bstr_alloc(ctx, &out_p, vb, NULL, arg->vb_length, arg->tainted) < 0) {
                talloc_free(vb);
                RPEDEBUG("Failed allocating space for unescaped string");
                return XLAT_ACTION_FAIL;
        }
-       sbuff = FR_SBUFF_IN(out_p, arg->length);
+       sbuff = FR_SBUFF_IN(out_p, arg->vb_length);
 
        p = arg->vb_strvalue;
-       end = p + arg->length;
+       end = p + arg->vb_length;
        while (*p) {
                if (*p != '=') {
                next:
index 73db03f10f487a69d59a40094f63c2e6c6bcabb6..99544db14a93a48b02a115e49ca59dc1996943c6 100644 (file)
@@ -197,7 +197,7 @@ static xlat_action_t ldap_escape_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
         *      Maximum space needed for output would be 3 times the input if every
         *      char needed escaping
         */
-       if (!fr_sbuff_init_talloc(vb, &sbuff, &sbuff_ctx, in_vb->length * 3, in_vb->length * 3)) {
+       if (!fr_sbuff_init_talloc(vb, &sbuff, &sbuff_ctx, in_vb->vb_length * 3, in_vb->vb_length * 3)) {
                REDEBUG("Failed to allocate buffer for escaped string");
                talloc_free(vb);
                return XLAT_ACTION_FAIL;
@@ -206,7 +206,7 @@ static xlat_action_t ldap_escape_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
        /*
         *      Call the escape function, including the space for the trailing NULL
         */
-       len = fr_ldap_escape_func(request, fr_sbuff_buff(&sbuff), in_vb->length * 3 + 1, in_vb->vb_strvalue, NULL);
+       len = fr_ldap_escape_func(request, fr_sbuff_buff(&sbuff), in_vb->vb_length * 3 + 1, in_vb->vb_strvalue, NULL);
 
        /*
         *      Trim buffer to fit used space and assign to box
@@ -234,7 +234,7 @@ static xlat_action_t ldap_unescape_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
        /*
         *      Maximum space needed for output will be the same as the input
         */
-       if (!fr_sbuff_init_talloc(vb, &sbuff, &sbuff_ctx, in_vb->length, in_vb->length)) {
+       if (!fr_sbuff_init_talloc(vb, &sbuff, &sbuff_ctx, in_vb->vb_length, in_vb->vb_length)) {
                REDEBUG("Failed to allocate buffer for unescaped string");
                talloc_free(vb);
                return XLAT_ACTION_FAIL;
@@ -243,7 +243,7 @@ static xlat_action_t ldap_unescape_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
        /*
         *      Call the unescape function, including the space for the trailing NULL
         */
-       len = fr_ldap_unescape_func(request, fr_sbuff_buff(&sbuff), in_vb->length + 1, in_vb->vb_strvalue, NULL);
+       len = fr_ldap_unescape_func(request, fr_sbuff_buff(&sbuff), in_vb->vb_length + 1, in_vb->vb_strvalue, NULL);
 
        /*
         *      Trim buffer to fit used space and assign to box
@@ -268,7 +268,7 @@ static int uri_part_escape(fr_value_box_t *vb, UNUSED void *uctx)
         *      Maximum space needed for output would be 3 times the input if every
         *      char needed escaping
         */
-       if (!fr_sbuff_init_talloc(vb, &sbuff, &sbuff_ctx, vb->length * 3, vb->length * 3)) {
+       if (!fr_sbuff_init_talloc(vb, &sbuff, &sbuff_ctx, vb->vb_length * 3, vb->vb_length * 3)) {
                fr_strerror_printf_push("Failed to allocate buffer for escaped argument");
                return -1;
        }
@@ -276,7 +276,7 @@ static int uri_part_escape(fr_value_box_t *vb, UNUSED void *uctx)
        /*
         *      Call the escape function, including the space for the trailing NULL
         */
-       len = fr_ldap_escape_func(NULL, fr_sbuff_buff(&sbuff), vb->length * 3 + 1, vb->vb_strvalue, NULL);
+       len = fr_ldap_escape_func(NULL, fr_sbuff_buff(&sbuff), vb->vb_length * 3 + 1, vb->vb_strvalue, NULL);
 
        fr_sbuff_trim_talloc(&sbuff, len);
        fr_value_box_clear_value(vb);
index 3b0e8c86e7fbafbfd58133cdaaa612b1f20a3c7d..3ffee6df276bb08a98b4fd624ea56dc488e26846 100644 (file)
@@ -647,7 +647,7 @@ static xlat_action_t mschap_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
         */
        } else if (strncasecmp(arg->vb_strvalue, "NT-Hash", 7) == 0) {
                arg = fr_value_box_list_next(in, arg);
-               if ((!arg) || (arg->length == 0))
+               if ((!arg) || (arg->vb_length == 0))
                        return XLAT_ACTION_FAIL;
 
                if (mschap_nt_password_hash(buffer, arg->vb_strvalue) < 0) {
@@ -667,7 +667,7 @@ static xlat_action_t mschap_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
         */
        } else if (strncasecmp(arg->vb_strvalue, "LM-Hash", 7) == 0) {
                arg = fr_value_box_list_next(in, arg);
-               if ((!arg) || (arg->length == 0))
+               if ((!arg) || (arg->vb_length == 0))
                        return XLAT_ACTION_FAIL;
 
                smbdes_lmpwdhash(arg->vb_strvalue, buffer);
index dacd79eaea6517f7a0b82d8cfa61f8ecb11fd89e..9ecd71e5e6c713e58c909c5ecc418edc95ec0647 100644 (file)
@@ -285,7 +285,7 @@ static int perl_vblist_to_av(AV *av, FR_DLIST_HEAD(fr_value_box_list) *head) {
        while ((vb = fr_value_box_list_next(head, vb))) {
                switch (vb->type) {
                case FR_TYPE_STRING:
-                       sv = newSVpvn(vb->vb_strvalue, vb->length);
+                       sv = newSVpvn(vb->vb_strvalue, vb->vb_length);
                        break;
 
                case FR_TYPE_OCTETS:
@@ -484,9 +484,9 @@ static xlat_action_t perl_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
                                /*
                                 *      Single child value - add as scalar
                                 */
-                               if (child->length == 0) continue;
+                               if (child->vb_length == 0) continue;
                                DEBUG3("Passing single value %pV", child);
-                               sv = newSVpvn(child->vb_strvalue, child->length);
+                               sv = newSVpvn(child->vb_strvalue, child->vb_length);
                                if (child->tainted) SvTAINT(sv);
                                XPUSHs(sv_2mortal(sv));
                                continue;
index dba52c97e606761632488874b19d1dcc820bb986..dba74b23aace1502248d63b275d971b345e8fe0f 100644 (file)
@@ -343,13 +343,13 @@ static int uri_part_escape(fr_value_box_t *vb, void *uctx)
        fr_curl_io_request_t    *randle = talloc_get_type_abort(uctx, fr_curl_io_request_t);
        request_t               *request = randle->request;
 
-       escaped = curl_easy_escape(randle->candle, vb->vb_strvalue, vb->length);
+       escaped = curl_easy_escape(randle->candle, vb->vb_strvalue, vb->vb_length);
        if (!escaped) return -1;
 
        /*
         *      Returned string the same length - nothing changed
         */
-       if (strlen(escaped) == vb->length) {
+       if (strlen(escaped) == vb->vb_length) {
                RDEBUG4("Tainted value %pV needed no escaping", vb);
                curl_free(escaped);
                return 0;
index 58b37176c3c1ebc9d805e13af69650d53d4531a4..b6f62d91fa512f37e49ac7c5a536384c57afa058 100644 (file)
@@ -178,12 +178,12 @@ static int sql_xlat_escape(request_t *request, fr_value_box_t *vb, void *uctx)
        /*
         *      Maximum escaped length is 3 * original - if every character needs escaping
         */
-       if (!fr_sbuff_init_talloc(vb, &sbuff, &sbuff_ctx, vb->length * 3, vb->length * 3)) {
+       if (!fr_sbuff_init_talloc(vb, &sbuff, &sbuff_ctx, vb->vb_length * 3, vb->vb_length * 3)) {
                fr_strerror_printf_push("Failed to allocate buffer for escaped sql argument");
                return -1;
        }
 
-       len = inst->sql_escape_func(request, fr_sbuff_buff(&sbuff), vb->length * 3 + 1, vb->vb_strvalue, handle);
+       len = inst->sql_escape_func(request, fr_sbuff_buff(&sbuff), vb->vb_length * 3 + 1, vb->vb_strvalue, handle);
 
        /*
         *      fr_value_box_strdup_shallow resets the dlist entries - take a copy
index 77b8a42e6d63e494af760e544d811f6769716ade..d09309f898aa4132a87fb3457d3b9a4421ce6551 100644 (file)
@@ -351,7 +351,7 @@ static xlat_action_t xlat_unbound(TALLOC_CTX *ctx, fr_dcursor_t *out,
        fr_value_box_t                  *count_vb = fr_value_box_list_next(in, query_vb);
        unbound_request_t               *ur;
 
-       if (host_vb->length == 0) {
+       if (host_vb->vb_length == 0) {
                REDEBUG("Can't resolve zero length host");
                return XLAT_ACTION_FAIL;
        }
index bdea90fe8ebf05ed4dabb2b43b6469e8a2a9f9b8..8e8879f4f043b761754e3c128adb708f9610145b 100644 (file)
@@ -88,10 +88,10 @@ static xlat_action_t unpack_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
                }
        } else if (data_vb->type == FR_TYPE_STRING) {
                input = (uint8_t const *)data_vb->vb_strvalue;
-               input_len = data_vb->length;
+               input_len = data_vb->vb_length;
        } else {
                input = data_vb->vb_octets;
-               input_len = data_vb->length;
+               input_len = data_vb->vb_length;
        }
 
        offset = offset_vb->vb_uint32;