From: Alan T. DeKok Date: Thu, 16 Mar 2023 15:21:04 +0000 (-0400) Subject: use macro instead of oddly named field X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40c0c5d294e521dd7c9e8b5aa41dad80e1c7c80f;p=thirdparty%2Ffreeradius-server.git use macro instead of oddly named field --- diff --git a/src/lib/util/dict.h b/src/lib/util/dict.h index 6bd8482fe9e..e5e4af0b0c7 100644 --- a/src/lib/util/dict.h +++ b/src/lib/util/dict.h @@ -145,6 +145,7 @@ enum { #define fr_dict_attr_is_key_field(_da) ((_da)->flags.extra && ((_da)->flags.subtype == FLAG_KEY_FIELD)) #define da_is_bit_field(_da) ((_da)->flags.extra && ((_da)->flags.subtype == FLAG_BIT_FIELD)) #define da_is_length_field(_da) ((_da)->flags.extra && (((_da)->flags.subtype == FLAG_LENGTH_UINT8) || ((_da)->flags.subtype == FLAG_LENGTH_UINT16))) +#define da_length_offset(_da) ((_da)->flags.type_size) /** Extension identifier diff --git a/src/lib/util/struct.c b/src/lib/util/struct.c index 9429894f16f..efa3cd39f69 100644 --- a/src/lib/util/struct.c +++ b/src/lib/util/struct.c @@ -97,13 +97,13 @@ ssize_t fr_struct_from_network(TALLOC_CTX *ctx, fr_pair_list_t *out, struct_len |= p[1]; } - if (struct_len < parent->flags.type_size) { + if (struct_len < da_length_offset(parent)) { FR_PROTO_TRACE("Length header (%zu) is smaller than minimum value (%u)", struct_len, parent->flags.type_size); goto unknown; } - if ((p + struct_len + need - parent->flags.type_size) > end) { + if ((p + struct_len + need - da_length_offset(parent)) > end) { FR_PROTO_TRACE("Length header (%zu) is larger than remaining data (%zu)", struct_len + need, (end - p)); goto unknown; @@ -818,7 +818,7 @@ done: if (parent->flags.subtype == FLAG_LENGTH_UINT8) { length -= 1; - length += parent->flags.type_size; + length += da_length_offset(parent); if (length > UINT8_MAX) return -1; @@ -826,7 +826,7 @@ done: } else { length -= 2; - length += parent->flags.type_size; + length += da_length_offset(parent); if (length > UINT16_MAX) return -1;