From: Alan T. DeKok Date: Wed, 21 Dec 2022 17:46:08 +0000 (-0500) Subject: ensure that type_size and length are set for unknown vendors X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b51f714b02fc6f5a259b0b8947db9ea13172155;p=thirdparty%2Ffreeradius-server.git ensure that type_size and length are set for unknown vendors that information is used to encode attributes. --- diff --git a/src/lib/util/dict_unknown.c b/src/lib/util/dict_unknown.c index 2b00d3bd235..0868bdba49f 100644 --- a/src/lib/util/dict_unknown.c +++ b/src/lib/util/dict_unknown.c @@ -180,7 +180,12 @@ static fr_dict_attr_t *dict_unknown_alloc(TALLOC_CTX *ctx, fr_dict_attr_t const flags.is_unknown = 1; flags.array = 0; flags.has_value = 0; - flags.length = 0; /* not fixed length */ + if (type != FR_TYPE_VENDOR) { + flags.length = 0; /* not fixed length */ + } else { + flags.type_size = da->flags.type_size; + flags.length = da->flags.length; + } flags.extra = 0; /* diff --git a/src/tests/unit/protocols/radius/vendor.txt b/src/tests/unit/protocols/radius/vendor.txt index 3cddcf8bd7f..703e75cb921 100644 --- a/src/tests/unit/protocols/radius/vendor.txt +++ b/src/tests/unit/protocols/radius/vendor.txt @@ -109,5 +109,32 @@ match 1a 0b 00 00 00 09 01 05 66 6f 6f 1a 0b 00 00 00 09 01 05 62 61 72 encode-pair Cisco-AVPair = "foo", Cisco-AVPair = "bar" match 1a 0b 00 00 00 09 01 05 66 6f 6f 1a 0b 00 00 00 09 01 05 62 61 72 +# +# Unknown attributes with TLVs +# +encode-pair 26.6809.1 = 0xabcdef +match 1a 0b 00 00 1a 99 01 05 ab cd ef + +decode-pair - +match Vendor-Specific.6809.1 = 0xabcdef + +encode-pair 26.6809.1.2 = 0xabcdef +match 1a 0d 00 00 1a 99 01 07 02 05 ab cd ef + +# +# @todo - This should be Vendor-Specific.6809.1.2 = 0xabcdef +# +decode-pair - +match Vendor-Specific.6809.1 = 0x0205abcdef + +encode-pair 26.6809.1.2.3 = 0xabcdef +match 1a 0f 00 00 1a 99 01 09 02 07 03 05 ab cd ef + +# +# @todo - This should be Vendor-Specific.6809.1.2.3 = 0xabcdef +# +decode-pair - +match Vendor-Specific.6809.1 = 0x02070305abcdef + count -match 52 +match 64