]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
use union.datum as a generic pointer
authorAlan T. DeKok <aland@freeradius.org>
Tue, 15 Nov 2016 20:16:10 +0000 (15:16 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 15 Nov 2016 20:16:10 +0000 (15:16 -0500)
src/include/pair.h
src/lib/radius_encode.c
src/lib/value.c
src/main/map.c
src/modules/rlm_eap/lib/sim/sim_proto.c
src/modules/rlm_sometimes/rlm_sometimes.c

index 10350656ca70b962536b1e9a5ea31dc3a49108e7..4099739fbb3b4b4d351b288ed64b26999d19e5e9 100644 (file)
@@ -67,7 +67,7 @@ struct value_data {
        value_data_t                    *next;                  //!< Next in a series of value_data.
 
        union {
-               uint8_t                 data;                   //!< so we can refer to a FIELD and not to a UNION
+               uint8_t                 datum;                  //!< so we can refer to a FIELD and not to a UNION
 
                char const              *strvalue;              //!< Pointer to UTF-8 string.
                uint8_t const           *octets;                //!< Pointer to binary string.
index 5b62928913be60489abfc0fcac2bea3180e0380c..0963f53a7071ac95dac96d3ee4a605c3f15405eb 100644 (file)
@@ -448,7 +448,7 @@ ssize_t fr_radius_encode_value_hton(uint8_t *out, size_t outlen, VALUE_PAIR cons
        case PW_TYPE_ABINARY:
        case PW_TYPE_ETHERNET:
        case PW_TYPE_COMBO_IP_ADDR:
-               memcpy(out, &vp->data.data, outlen);
+               memcpy(out, &vp->data.datum, outlen);
                break;
 
        case PW_TYPE_BOOLEAN:
index a2a85a07a451567f17a52007d13c479ccbc6e5a4..c351f02051202997773764cd0b1c2e1218ccb284 100644 (file)
@@ -1200,7 +1200,8 @@ void value_data_hton(value_data_t *dst, PW_TYPE type, void const *src, size_t sr
                return;         /* shouldn't happen */
 
        default:
-               memcpy(dst, src, src_len);
+               memcpy(&dst->datum, src, src_len);
+               break;
        }
 }
 
@@ -1240,8 +1241,8 @@ int value_data_cast(TALLOC_CTX *ctx, value_data_t *dst,
         *      Converts the src data to octets with no processing.
         */
        if (dst_type == PW_TYPE_OCTETS) {
-               value_data_hton(dst, src_type, &src->data, src->length);
-               dst->octets = talloc_memdup(ctx, dst, src->length);
+               value_data_hton(dst, src_type, &src->datum, src->length);
+               dst->octets = talloc_memdup(ctx, &dst->datum, src->length);
                dst->length = src->length;
                talloc_set_type(dst->octets, uint8_t);
                return 0;
@@ -1656,7 +1657,7 @@ int value_data_cast(TALLOC_CTX *ctx, value_data_t *dst,
                dst->integer = htonl(src->ipaddr.s_addr);
 
        } else {                /* they're of the same byte order */
-               memcpy(&dst, &src, src->length);
+               memcpy(&dst->datum, &src->datum, src->length);
        }
        dst->length = src->length;
 
index b2488e3b7c91177c62367b10c8c0c0d0b543cde6..931934a618846a7be3ac2d02c443fb08399551fa 100644 (file)
@@ -142,7 +142,7 @@ bool map_cast_from_hex(vp_map_t *map, FR_TOKEN rhs_type, char const *rhs)
                        map->rhs->quote = T_BARE_WORD;
                }
        } else {
-               memcpy(&map->rhs->tmpl_data_value, &vp->data.data, sizeof(map->rhs->tmpl_data_value));
+               memcpy(&map->rhs->tmpl_data_value, &vp->data.datum, sizeof(map->rhs->tmpl_data_value));
                map->rhs->quote = T_BARE_WORD;
        }
        map->rhs->name = fr_pair_value_asprint(map->rhs, vp, fr_token_quote[map->rhs->quote]);
index c79588c502ffe109802e6f1fb98c5d66ef3ea227..63f375762481fa75a5a6c36309628f4207eba683 100644 (file)
@@ -938,7 +938,7 @@ ssize_t fr_sim_encode(REQUEST *request, fr_dict_attr_t const *parent, uint8_t ty
                {
                        value_data_t data;
 
-                       value_data_hton(&data, vp->da->type, &vp->data.data, vp->vp_length);
+                       value_data_hton(&data, vp->da->type, &vp->data.datum, vp->vp_length);
                        memcpy(&p[2], &data, vp->vp_length);
                }
 
@@ -948,7 +948,7 @@ ssize_t fr_sim_encode(REQUEST *request, fr_dict_attr_t const *parent, uint8_t ty
                 *      to limit to the types of the IANA registered attributes.
                 */
                default:
-                       memcpy(&p[2], &vp->data.data, vp->vp_length);
+                       memcpy(&p[2], &vp->data.datum, vp->vp_length);
                        break;
                }
 
index 93be3746cfed505be87c197de779837c467f4d24..09c0612560099ca43ebd2409330e3e6ce6ecce6a 100644 (file)
@@ -84,7 +84,7 @@ static rlm_rcode_t sometimes_return(void const *instance, REQUEST *request, RADI
        tmpl_find_vp(&vp, request, inst->key);
        if (!vp) return RLM_MODULE_NOOP;
 
-       hash = fr_hash(&vp->data.data, vp->vp_length);
+       hash = fr_hash(&vp->data.datum, vp->vp_length);
        hash &= 0xff;           /* ensure it's 0..255 */
        value = hash;