]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
some attempt to allow refs to non-root attributes
authorAlan T. DeKok <aland@freeradius.org>
Thu, 5 Dec 2024 21:36:27 +0000 (16:36 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 7 Dec 2024 14:36:44 +0000 (09:36 -0500)
src/protocols/dhcpv6/decode.c
src/protocols/dhcpv6/encode.c
src/tests/unit/protocols/dhcpv6/group-tlv.txt

index 034b2c8e043162b0c310e2ae661907f1259e8d79..b52d225a31da6f9bb8b11c204a07848fe985f774 100644 (file)
@@ -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;
                }
 
index 84989eb5d2a83a0288dc95762277fe80ea73bcdb..94deb358b82f5e1a537137694e6474ddb181bec3 100644 (file)
@@ -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);
 
index 31dce26dd5bbfe9cf9bcee8bd9a3a581001c740b..a6a34289543e50e37063daaeb63ea160e269b179 100644 (file)
@@ -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