]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
switch encoders to use vp->vp_type
authorAlan T. DeKok <aland@freeradius.org>
Sat, 9 Sep 2023 11:29:19 +0000 (07:29 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 9 Sep 2023 11:29:19 +0000 (07:29 -0400)
because vp_type could be different from da->type in some cases

src/bin/radsnmp.c
src/lib/eap_aka_sim/encode.c
src/protocols/dhcpv6/encode.c
src/protocols/dns/encode.c
src/protocols/internal/encode.c
src/protocols/radius/encode.c

index c9358de3fc7bb707376759acf1e59743dbbe318c..405335d4bce0345d14e7c93ab06bd1b6f2dc3810 100644 (file)
@@ -325,7 +325,7 @@ static ssize_t radsnmp_pair_from_oid(TALLOC_CTX *ctx, radsnmp_conf_t *conf, fr_d
         *      fr_pair_ts with no value need a 1 byte value buffer.
         */
        if (!value) {
-               switch (da->type) {
+               switch (vp->vp_type) {
                case FR_TYPE_OCTETS:
                        fr_pair_value_memdup(vp, (uint8_t const *)"\0", 1, true);
                        break;
index f024427d0fa1205ce01b651ea9a629a9b054354d..eec1e4776118e6fb891a101df9c0b31c059420fd 100644 (file)
@@ -289,7 +289,7 @@ static ssize_t encode_value(fr_dbuff_t *dbuff,
                return PAIR_ENCODE_FATAL_ERROR;
        }
 
-       switch (da->type) {
+       switch (vp->vp_type) {
        case FR_TYPE_STRUCTURAL:
                fr_strerror_printf("%s: Called with structural type %s", __FUNCTION__,
                                   fr_type_to_str(da_stack->da[depth]->type));
@@ -375,7 +375,7 @@ static ssize_t encode_value(fr_dbuff_t *dbuff,
                break;
        }
 
-       switch (da->type) {
+       switch (vp->vp_type) {
        /*
         *      In order to represent the string length properly we include a second
         *      16bit length field with the real string length.
index b28133ce84cef4020cadaf58101a958274fb1bc2..7f8193eab44766b22f33e5b349f4430f624c633f 100644 (file)
@@ -118,7 +118,7 @@ static ssize_t encode_value(fr_dbuff_t *dbuff,
                return PAIR_ENCODE_FATAL_ERROR;
        }
 
-       switch (da->type) {
+       switch (vp->vp_type) {
        case FR_TYPE_TLV:
        case FR_TYPE_VENDOR:
        case FR_TYPE_VSA:
@@ -126,12 +126,6 @@ static ssize_t encode_value(fr_dbuff_t *dbuff,
                                   fr_type_to_str(da->type));
                return PAIR_ENCODE_FATAL_ERROR;
 
-       default:
-               break;
-       }
-
-
-       switch (da->type) {
        /*
         *    0                   1                   2                   3
         *    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
index 7dad54b7e59c4ebccc601d3af2a838773f9aeabe..9b1e23b40e5b1224790d7d82913f1d4726ebf07b 100644 (file)
@@ -136,7 +136,7 @@ static ssize_t encode_value(fr_dbuff_t *dbuff,
                return PAIR_ENCODE_FATAL_ERROR;
        }
 
-       switch (da->type) {
+       switch (vp->vp_type) {
        case FR_TYPE_TLV:
        case FR_TYPE_VENDOR:
        case FR_TYPE_VSA:
@@ -145,12 +145,6 @@ static ssize_t encode_value(fr_dbuff_t *dbuff,
                                   fr_type_to_str(da->type));
                return PAIR_ENCODE_FATAL_ERROR;
 
-       default:
-               break;
-       }
-
-
-       switch (da->type) {
        case FR_TYPE_STRING:
                /*
                 *      DNS labels get a special encoder.
@@ -189,10 +183,6 @@ static ssize_t encode_value(fr_dbuff_t *dbuff,
                 */
                break;
 
-       case FR_TYPE_GROUP:
-               fr_strerror_const("invalid data type - group");
-               return PAIR_ENCODE_FATAL_ERROR;
-
        /*
         *      The value_box functions will take care of fixed-width
         *      "string" and "octets" options.
index 4dfb5164af438b434a948f02feb9983180702e22..29240906c420306bbe21a706af85af4d0b952baf 100644 (file)
@@ -74,7 +74,7 @@ static ssize_t internal_encode(fr_dbuff_t *dbuff,
 
        fr_assert(!da->flags.name_only);
 
-       switch (da->type) {
+       switch (vp->vp_type) {
        /*
         *      Only leaf attributes can be tainted
         */
@@ -126,7 +126,7 @@ static ssize_t internal_encode(fr_dbuff_t *dbuff,
        value_dbuff = FR_DBUFF_BIND_CURRENT(&work_dbuff);
        fr_dbuff_marker(&value_field, &value_dbuff);
 
-       switch (da->type) {
+       switch (vp->vp_type) {
        case FR_TYPE_LEAF:
                slen = fr_value_box_to_network(&value_dbuff, &vp->data);
                if (slen < 0) return PAIR_ENCODE_FATAL_ERROR;
index 587f7575251161e4e3674aff77413c213421b4f2..aa63640349bc0f09c0c4988333d30f22fc5bdf91 100644 (file)
@@ -424,7 +424,7 @@ static ssize_t encode_value(fr_dbuff_t *dbuff,
        fr_dbuff_marker(&src, &value_dbuff);
        fr_dbuff_marker(&dest, &value_dbuff);
 
-       switch (da->type) {
+       switch (vp->vp_type) {
                /*
                 *      IPv4 addresses are normal, but IPv6 addresses are special to RADIUS.
                 */