From: Alan T. DeKok Date: Fri, 13 Aug 2021 17:42:18 +0000 (-0400) Subject: arrays of string/octets are encoded as 16-bit length + data X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3076962bc982ac8ec75a45be22b40279e261d16d;p=thirdparty%2Ffreeradius-server.git arrays of string/octets are encoded as 16-bit length + data which are fixed size. And, clamp the maximum encoded value to 16-bits, too --- diff --git a/src/protocols/dhcpv6/base.c b/src/protocols/dhcpv6/base.c index 12537f83bac..03f0a8971ac 100644 --- a/src/protocols/dhcpv6/base.c +++ b/src/protocols/dhcpv6/base.c @@ -161,6 +161,14 @@ size_t fr_dhcpv6_option_len(fr_pair_t const *vp) #endif if (vp->da->flags.length) return vp->da->flags.length; /* Variable type with fixed length */ + + /* + * Arrays get maxed at 2^16-1 + */ + if (vp->da->flags.array && ((vp->vp_type == FR_TYPE_STRING) || (vp->vp_type == FR_TYPE_OCTETS))) { + if (vp->vp_length > 65535) return 65535; + } + return vp->vp_length; case FR_TYPE_DATE: @@ -1020,6 +1028,14 @@ void fr_dhcpv6_global_free(void) static bool attr_valid(UNUSED fr_dict_t *dict, UNUSED fr_dict_attr_t const *parent, UNUSED char const *name, UNUSED int attr, fr_type_t type, fr_dict_attr_flags_t *flags) { + /* + * "arrays" of string/octets are encoded as a 16-bit + * length, followed by the actual data. + */ + if (flags->array && ((type == FR_TYPE_STRING) || (type == FR_TYPE_OCTETS))) { + flags->is_known_width = true; + } + /* * "extra" signifies that subtype is being used by the * dictionaries itself.