]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
don't manually set VT_DATA everywhere
authorAlan T. DeKok <aland@freeradius.org>
Sat, 11 Dec 2021 00:09:29 +0000 (19:09 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 11 Dec 2021 00:09:29 +0000 (19:09 -0500)
it should be the default, unless we add a new API to allow
fr_pair_t to contain fr_value_box_list_t

src/lib/eap_aka_sim/decode.c
src/lib/util/pair.c
src/lib/util/pair.h
src/lib/util/struct.c
src/listen/detail/proto_detail.c
src/protocols/dhcpv6/base.c
src/protocols/dhcpv6/decode.c
src/protocols/dns/decode.c
src/protocols/radius/decode.c

index a05c0cfb2aabf7c950523af9067bf85e67009213..e8cb3acf174245fae8fe89ec227a4b4c1b056ad7 100644 (file)
@@ -823,7 +823,6 @@ static ssize_t sim_decode_pair_value(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_di
        }
 
 done:
-       vp->type = VT_DATA;
        fr_pair_append(out, vp);
 
        return attr_len;
index 7691bae43193c9508d867b5911ad5ab2eff1ba53..5ca5ea3e0daa365393af339126eef00014450d3c 100644 (file)
@@ -113,7 +113,7 @@ static inline CC_HINT(always_inline) void pair_init_null(fr_pair_t *vp)
         *      Legacy cruft
         */
        vp->op = T_OP_EQ;
-       vp->type = VT_NONE;
+       vp->type = VT_DATA;
 }
 
 /** Dynamically allocate a new attribute with no #fr_dict_attr_t assigned
@@ -1937,7 +1937,6 @@ int fr_pair_value_from_str(fr_pair_t *vp, char const *value, size_t inlen,
                                  value, inlen,
                                  uerules,
                                  tainted) < 0) return -1;
-       vp->type = VT_DATA;
 
        PAIR_VERIFY(vp);
 
@@ -1964,7 +1963,6 @@ int fr_pair_value_strdup(fr_pair_t *vp, char const *src, bool tainted)
        fr_value_box_clear(&vp->data);  /* Free any existing buffers */
        ret = fr_value_box_strdup(vp, &vp->data, vp->da, src, tainted);
        if (ret == 0) {
-               vp->type = VT_DATA;
                PAIR_VERIFY(vp);
        }
 
@@ -1987,7 +1985,6 @@ int fr_pair_value_strdup_shallow(fr_pair_t *vp, char const *src, bool tainted)
        fr_value_box_clear(&vp->data);
        fr_value_box_strdup_shallow(&vp->data, vp->da, src, tainted);
 
-       vp->type = VT_DATA;
        PAIR_VERIFY(vp);
 
        return 0;
@@ -2008,7 +2005,6 @@ int fr_pair_value_strtrim(fr_pair_t *vp)
 
        ret = fr_value_box_strtrim(vp, &vp->data);
        if (ret == 0) {
-               vp->type = VT_DATA;
                PAIR_VERIFY(vp);
        }
 
@@ -2035,12 +2031,10 @@ int fr_pair_value_aprintf(fr_pair_t *vp, char const *fmt, ...)
        va_end(ap);
 
        if (ret == 0) {
-               vp->type = VT_DATA;
                PAIR_VERIFY(vp);
-               return 0;
        }
 
-       return -1;
+       return ret;
 }
 
 /** Pre-allocate a memory buffer for a "string" type value pair
@@ -2065,7 +2059,6 @@ int fr_pair_value_bstr_alloc(fr_pair_t *vp, char **out, size_t size, bool tainte
        fr_value_box_clear(&vp->data);  /* Free any existing buffers */
        ret = fr_value_box_bstr_alloc(vp, out, &vp->data, vp->da, size, tainted);
        if (ret == 0) {
-               vp->type = VT_DATA;
                PAIR_VERIFY(vp);
        }
 
@@ -2090,7 +2083,6 @@ int fr_pair_value_bstr_realloc(fr_pair_t *vp, char **out, size_t size)
 
        ret = fr_value_box_bstr_realloc(vp, out, &vp->data, size);
        if (ret == 0) {
-               vp->type = VT_DATA;
                PAIR_VERIFY(vp);
        }
 
@@ -2121,7 +2113,6 @@ int fr_pair_value_bstrndup(fr_pair_t *vp, char const *src, size_t len, bool tain
        fr_value_box_clear(&vp->data);
        ret = fr_value_box_bstrndup(vp, &vp->data, vp->da, src, len, tainted);
        if (ret == 0) {
-               vp->type = VT_DATA;
                PAIR_VERIFY(vp);
        }
 
@@ -2148,7 +2139,6 @@ int fr_pair_value_bstrdup_buffer(fr_pair_t *vp, char const *src, bool tainted)
        fr_value_box_clear(&vp->data);
        ret = fr_value_box_bstrdup_buffer(vp, &vp->data, vp->da, src, tainted);
        if (ret == 0) {
-               vp->type = VT_DATA;
                PAIR_VERIFY(vp);
        }
 
@@ -2171,7 +2161,6 @@ int fr_pair_value_bstrndup_shallow(fr_pair_t *vp, char const *src, size_t len, b
 
        fr_value_box_clear(&vp->data);
        fr_value_box_bstrndup_shallow(&vp->data, vp->da, src, len, tainted);
-       vp->type = VT_DATA;
        PAIR_VERIFY(vp);
 
        return 0;
@@ -2195,7 +2184,6 @@ int fr_pair_value_bstrdup_buffer_shallow(fr_pair_t *vp, char const *src, bool ta
        fr_value_box_clear(&vp->data);
        ret = fr_value_box_bstrdup_buffer_shallow(NULL, &vp->data, vp->da, src, tainted);
        if (ret == 0) {
-               vp->type = VT_DATA;
                PAIR_VERIFY(vp);
        }
 
@@ -2220,7 +2208,6 @@ int fr_pair_value_bstrn_append(fr_pair_t *vp, char const *src, size_t len, bool
 
        ret = fr_value_box_bstrn_append(vp, &vp->data, src, len, tainted);
        if (ret == 0) {
-               vp->type = VT_DATA;
                PAIR_VERIFY(vp);
        }
 
@@ -2244,7 +2231,6 @@ int fr_pair_value_bstr_append_buffer(fr_pair_t *vp, char const *src, bool tainte
 
        ret = fr_value_box_bstr_append_buffer(vp, &vp->data, src, tainted);
        if (ret == 0) {
-               vp->type = VT_DATA;
                PAIR_VERIFY(vp);
        }
 
@@ -2273,7 +2259,6 @@ int fr_pair_value_mem_alloc(fr_pair_t *vp, uint8_t **out, size_t size, bool tain
        fr_value_box_clear(&vp->data);  /* Free any existing buffers */
        ret = fr_value_box_mem_alloc(vp, out, &vp->data, vp->da, size, tainted);
        if (ret == 0) {
-               vp->type = VT_DATA;
                PAIR_VERIFY(vp);
        }
 
@@ -2298,7 +2283,6 @@ int fr_pair_value_mem_realloc(fr_pair_t *vp, uint8_t **out, size_t size)
 
        ret = fr_value_box_mem_realloc(vp, out, &vp->data, size);
        if (ret == 0) {
-               vp->type = VT_DATA;
                PAIR_VERIFY(vp);
        }
 
@@ -2326,7 +2310,6 @@ int fr_pair_value_memdup(fr_pair_t *vp, uint8_t const *src, size_t size, bool ta
        fr_value_box_clear(&vp->data);  /* Free any existing buffers */
        ret = fr_value_box_memdup(vp, &vp->data, vp->da, src, size, tainted);
        if (ret == 0) {
-               vp->type = VT_DATA;
                PAIR_VERIFY(vp);
        }
 
@@ -2353,7 +2336,6 @@ int fr_pair_value_memdup_buffer(fr_pair_t *vp, uint8_t const *src, bool tainted)
        fr_value_box_clear(&vp->data);  /* Free any existing buffers */
        ret = fr_value_box_memdup_buffer(vp, &vp->data, vp->da, src, tainted);
        if (ret == 0) {
-               vp->type = VT_DATA;
                PAIR_VERIFY(vp);
        }
 
@@ -2376,7 +2358,6 @@ int fr_pair_value_memdup_shallow(fr_pair_t *vp, uint8_t const *src, size_t len,
 
        fr_value_box_clear(&vp->data);
        fr_value_box_memdup_shallow(&vp->data, vp->da, src, len, tainted);
-       vp->type = VT_DATA;
        PAIR_VERIFY(vp);
 
        return 0;
@@ -2397,7 +2378,6 @@ int fr_pair_value_memdup_buffer_shallow(fr_pair_t *vp, uint8_t const *src, bool
 
        fr_value_box_clear(&vp->data);
        fr_value_box_memdup_buffer_shallow(NULL, &vp->data, vp->da, src, tainted);
-       vp->type = VT_DATA;
        PAIR_VERIFY(vp);
 
        return 0;
@@ -2422,7 +2402,6 @@ int fr_pair_value_mem_append(fr_pair_t *vp, uint8_t *src, size_t len, bool taint
 
        ret = fr_value_box_mem_append(vp, &vp->data, src, len, tainted);
        if (ret == 0) {
-               vp->type = VT_DATA;
                PAIR_VERIFY(vp);
        }
 
@@ -2446,7 +2425,6 @@ int fr_pair_value_mem_append_buffer(fr_pair_t *vp, uint8_t *src, bool tainted)
 
        ret = fr_value_box_mem_append_buffer(vp, &vp->data, src, tainted);
        if (ret == 0) {
-               vp->type = VT_DATA;
                PAIR_VERIFY(vp);
        }
 
index f2894ab85d98871c184d0d73638e1c0d1c33ff56..763eb86663d0e369c816352f84b01fdabd36135a 100644 (file)
@@ -51,9 +51,8 @@ extern "C" {
  * xlat is another type of data node which must first be expanded before use.
  */
 typedef enum value_type {
-       VT_NONE = 0,                                            //!< fr_pair_t has no value.
-       VT_SET,                                                 //!< fr_pair_t has children.
-       VT_LIST,                                                //!< fr_pair_t has multiple values.
+       VT_INVALID = 0,                                         //!< fr_pair_t is broken
+       VT_SET,                                                 //!< fr_pair_t is #fr_value_box_list
        VT_DATA,                                                //!< fr_pair_t has a single value.
 } value_type_t;
 
index 9ff0aa9a2897d252663f46e327a71d8a372c0a56..621a49a551857b2d35ac2a034820484ab5b2738c 100644 (file)
@@ -53,7 +53,6 @@ fr_pair_t *fr_raw_from_network(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, ui
                return NULL;
        }
 
-       vp->type = VT_DATA;
        return vp;
 }
 
@@ -200,7 +199,6 @@ ssize_t fr_struct_from_network(TALLOC_CTX *ctx, fr_pair_list_t *out,
                                        goto unknown;
                        }
 
-                       vp->type = VT_DATA;
                        vp->vp_tainted = true;
                        fr_pair_append(child_list, vp);
                        p += (num_bits >> 3); /* go to the LAST bit, not the byte AFTER the last bit */
@@ -318,7 +316,6 @@ ssize_t fr_struct_from_network(TALLOC_CTX *ctx, fr_pair_list_t *out,
                        return data_len;
                }
 
-               vp->type = VT_DATA;
                vp->vp_tainted = true;
                fr_pair_append(child_list, vp);
 
index 2e994c31ff57d7c8eebe51905a9c9d197881f324..9d617087c5aa0592ad57074ed570b7e99b22f53d 100644 (file)
@@ -276,7 +276,6 @@ static int mod_decode(void const *instance, request_t *request, uint8_t *const d
                        vp = fr_pair_afrom_da(request->request_ctx, attr_packet_original_timestamp);
                        if (vp) {
                                vp->vp_date = fr_unix_time_from_sec(timestamp);
-                               vp->type = VT_DATA;
                                fr_dcursor_append(&cursor, vp);
                        }
                        goto next;
index 1f00ef2e83af639a28b52b41601a5538f590bd90..1700d4d0dd2be54ae6baf24efef5dfc26c9fb5fc 100644 (file)
@@ -662,7 +662,6 @@ ssize_t     fr_dhcpv6_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *pa
        if (!vp) return -1;
 
        vp->vp_uint32 = packet[0];
-       vp->type = VT_DATA;
        fr_pair_append(&tmp, vp);
 
        switch (packet[0]) {
@@ -723,7 +722,6 @@ ssize_t     fr_dhcpv6_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *pa
         */
        (void) fr_pair_value_memdup(vp, packet + 1, 3, false);
 
-       vp->type = VT_DATA;
        fr_pair_append(&tmp, vp);
 
        p = packet + 4;
index 4dd2fa297e67685a9ba9ef5350b11fcf9827134b..a82c937056b6be2ef55cf496e4cd084724ab255d 100644 (file)
@@ -91,7 +91,6 @@ static ssize_t decode_raw(TALLOC_CTX *ctx, fr_pair_list_t *out, UNUSED fr_dict_t
                return slen;
        }
 
-       vp->type = VT_DATA;
        vp->vp_tainted = true;
        fr_pair_append(out, vp);
        return data_len;
@@ -266,7 +265,6 @@ static ssize_t decode_value(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_t cons
                break;
        }
 
-       vp->type = VT_DATA;
        vp->vp_tainted = true;
        fr_pair_append(out, vp);
        return data_len;
@@ -410,7 +408,6 @@ static ssize_t decode_dns_labels(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_t
                        goto raw;
                }
 
-               vp->type = VT_DATA;
                fr_pair_append(out, vp);
        }
 
index 6dd5d378fd66a62c4126f9b84eeaf48a2e2d3143..4edbe465007968c7a663fd3f65cca44c39fbbfb5 100644 (file)
@@ -73,7 +73,6 @@ static ssize_t decode_raw(TALLOC_CTX *ctx, fr_pair_list_t *out, UNUSED fr_dict_t
                return slen;
        }
 
-       vp->type = VT_DATA;
        vp->vp_tainted = true;
        fr_pair_append(out, vp);
        return data_len;
@@ -223,7 +222,6 @@ static ssize_t decode_value(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_t cons
                break;
        }
 
-       vp->type = VT_DATA;
        vp->vp_tainted = true;
        fr_pair_append(out, vp);
        return data_len;
@@ -375,7 +373,6 @@ static ssize_t decode_dns_labels(TALLOC_CTX *ctx, fr_pair_list_t *out,UNUSED fr_
                        return -1;
                }
 
-               vp->type = VT_DATA;
                fr_pair_append(out, vp);
        }
 
index f0ce23dd637620fd1c320a4ce8a90ad4ecf1329f..c9b8316cdd010237bdf5cac4f772147683eb3936 100644 (file)
@@ -1706,7 +1706,6 @@ ssize_t fr_radius_decode_pair_value(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dic
        }
 
 done:
-       vp->type = VT_DATA;
        vp->vp_tainted = true;
 
        if (!tag) {