From: James Jones Date: Tue, 15 Mar 2022 12:13:44 +0000 (-0500) Subject: Allow string/octet "arrays" with length=uint8 (#4415) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8de88078d1a00b79202e5f20f854a48ba4b07b87;p=thirdparty%2Ffreeradius-server.git Allow string/octet "arrays" with length=uint8 (#4415) This is the DHCPv4 analog of 64ea2f5, the analogous DHCPv6 change. --- diff --git a/src/protocols/dhcpv4/base.c b/src/protocols/dhcpv4/base.c index 71dfc3b237d..e9f0ac703d2 100644 --- a/src/protocols/dhcpv4/base.c +++ b/src/protocols/dhcpv4/base.c @@ -659,7 +659,18 @@ static fr_table_num_ordered_t const subtype_table[] = { 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) { - if (flags->array && !flags->length) { + /* + * "arrays" of string/octets are encoded as a 8-bit + * length, followed by the actual data. + */ + if (flags->array && ((type == FR_TYPE_STRING) || (type == FR_TYPE_OCTETS))) { + flags->is_known_width = true; + + if (flags->extra && (flags->subtype != FLAG_LENGTH_UINT8)) { + fr_strerror_const("string/octets arrays require the 'length=uint8' flag"); + return false; + } + } else if (flags->array && !flags->length) { fr_strerror_const("Variable length attributes cannot be marked as 'array'"); return false; }