From: Alan T. DeKok Date: Thu, 5 Dec 2024 21:36:27 +0000 (-0500) Subject: some attempt to allow refs to non-root attributes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b40dbb77544feb0a2f2009b283236044bc295f8;p=thirdparty%2Ffreeradius-server.git some attempt to allow refs to non-root attributes --- diff --git a/src/protocols/dhcpv6/decode.c b/src/protocols/dhcpv6/decode.c index 034b2c8e043..b52d225a31d 100644 --- a/src/protocols/dhcpv6/decode.c +++ b/src/protocols/dhcpv6/decode.c @@ -206,11 +206,13 @@ static ssize_t decode_value(TALLOC_CTX *ctx, fr_pair_list_t *out, vp->vp_tainted = true; } else { + if (!ref) ref = fr_dict_root(dict_dhcpv6); + /* * Child VPs go into the child group, not in the main parent list. BUT, we start - * decoding attributes from the dictionary root, not from this parent. + * decoding attributes from the ref, and not from the group parent. */ - slen = fr_pair_tlvs_from_network(vp, &vp->vp_group, fr_dict_root(dict_dhcpv6), data, data_len, decode_ctx, decode_option, NULL, false); + slen = fr_pair_tlvs_from_network(vp, &vp->vp_group, ref, data, data_len, decode_ctx, decode_option, NULL, false); if (slen < 0) goto raw_free; } diff --git a/src/protocols/dhcpv6/encode.c b/src/protocols/dhcpv6/encode.c index 84989eb5d2a..94deb358b82 100644 --- a/src/protocols/dhcpv6/encode.c +++ b/src/protocols/dhcpv6/encode.c @@ -292,6 +292,11 @@ static ssize_t encode_value(fr_dbuff_t *dbuff, if (!fr_pair_list_empty(&vp->vp_group)) { (void) fr_pair_dcursor_child_iter_init(&child_cursor, &vp->vp_group, cursor); + /* + * @todo - encode from "ref" and not from the root? But that's hard, + * due to the whole proto stack thing, which we largely don't need + * any more. + */ while (fr_dcursor_current(&child_cursor) != NULL) { slen = fr_dhcpv6_encode_option(&work_dbuff, &child_cursor, encode_ctx); diff --git a/src/tests/unit/protocols/dhcpv6/group-tlv.txt b/src/tests/unit/protocols/dhcpv6/group-tlv.txt index 31dce26dd5b..a6a34289543 100644 --- a/src/tests/unit/protocols/dhcpv6/group-tlv.txt +++ b/src/tests/unit/protocols/dhcpv6/group-tlv.txt @@ -13,17 +13,24 @@ fuzzer-out dhcpv6 pair test-group = { child1 = 1 } match test-group = { child1 = 1 } -encode-pair test-group = { child1 = 1 } -match 1a 9a 00 0c 1a 99 00 08 00 01 00 04 00 00 00 01 +# +# This doesn't have Test-tlv encoded +# +decode-pair 1a 9a 00 08 00 01 00 04 00 00 00 01 +match test-group = { child1 = 1 } # -# Yeah, this is wrong. The decoder can only handle group refs which -# point to the top of the tree. +# However, this does encode Test-TLV, which is wrong. +# +encode-pair test-group = { child1 = 1 } +match 1a 9a 00 0c 1a 99 00 08 00 01 00 04 00 00 00 01 + # -# @todo - fix it! +# Sadly, there is no child 6809 of the group ref, so this decode +# is all raw. :( # decode-pair - -match test-group = { test-tlv = { child1 = 1 } } +match test-group = { raw.6809 = 0x0001000400000001 } count -match 10 +match 12