]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Revert "decode RADIUS TLVs as nested pairs."
authorAlan T. DeKok <aland@freeradius.org>
Thu, 8 Apr 2021 19:11:07 +0000 (15:11 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 8 Apr 2021 19:11:42 +0000 (15:11 -0400)
This reverts commit 6aea55db373640a88a736a236c4c551aa1ff0a35.

this breaks the digest tests, and we want to have the master
branch passing

src/lib/util/pair_print.c
src/protocols/radius/decode.c
src/tests/unit/protocols/radius/rfc8045.txt
src/tests/unit/protocols/radius/struct.txt
src/tests/unit/protocols/radius/unit.txt
src/tests/unit/protocols/radius/wimax.txt

index 7957ffad590f99587ca688eba054ba81317286c3..96a9caa7839687ec35b43e66abefdc00d6430048 100644 (file)
@@ -132,10 +132,6 @@ ssize_t fr_pair_print(fr_sbuff_t *out, fr_pair_t const *parent, fr_pair_t const
  * Complete string with '\\t' and '\\n' is written to buffer before printing to
  * avoid issues when running with multiple threads.
  *
- * This function will print *flattened* lists, as is suitable for use
- * with rlm_detail.  In fact, the only user of this function is
- * rlm_detail.
- *
  * @param fp to output to.
  * @param vp to print.
  */
index 3635ed3b67e5855cae715aee68f02e3fb55735d4..6992a733bafb227d36a94fa06c0c55c0a71bf0d9 100644 (file)
@@ -419,7 +419,6 @@ ssize_t fr_radius_decode_tlv(TALLOC_CTX *ctx, fr_dcursor_t *cursor, fr_dict_t co
        fr_dict_attr_t const    *child;
        fr_pair_list_t          head;
        fr_dcursor_t            tlv_cursor;
-       fr_pair_t               *vp;
 
        fr_pair_list_init(&head);
        if (data_len < 3) return -1; /* type, length, value */
@@ -432,12 +431,8 @@ ssize_t fr_radius_decode_tlv(TALLOC_CTX *ctx, fr_dcursor_t *cursor, fr_dict_t co
 
        if (fr_radius_decode_tlv_ok(p, data_len, 1, 1) < 0) return -1;
 
-       vp = fr_pair_afrom_da(ctx, parent);
-       if (!vp) return PAIR_DECODE_OOM;
-
        /*
-        *       Create a temporary sub-list, so decode errors don't
-        *       affect the main list.
+        *  Record where we were in the list when this function was called
         */
        fr_dcursor_init(&tlv_cursor, &head);
        while (p < end) {
@@ -453,21 +448,21 @@ ssize_t fr_radius_decode_tlv(TALLOC_CTX *ctx, fr_dcursor_t *cursor, fr_dict_t co
                        child = fr_dict_unknown_attr_afrom_num(packet_ctx->tmp_ctx, parent, p[0]);
                        if (!child) {
                        error:
-                               talloc_free(vp);
+                               fr_pair_list_free(&head);
                                return -1;
                        }
                }
                FR_PROTO_TRACE("decode context changed %s -> %s", parent->name, child->name);
 
-               tlv_len = fr_radius_decode_pair_value(vp, &tlv_cursor, dict,
+               tlv_len = fr_radius_decode_pair_value(ctx, &tlv_cursor, dict,
                                                      child, p + 2, p[1] - 2, p[1] - 2,
                                                      packet_ctx);
                if (tlv_len < 0) goto error;
                p += p[1];
        }
-
-       fr_tmp_pair_list_move(&vp->vp_group, &head);
-       fr_dcursor_append(cursor, vp);
+       fr_dcursor_head(&tlv_cursor);
+       fr_dcursor_tail(cursor);
+       fr_dcursor_merge(cursor, &tlv_cursor);  /* Wind to the end of the new pairs */
 
        return data_len;
 }
index d9ad7eb47e9b9773ddabf902a31114cf3fc05b85..a9e3659e958f596e2c857529346cda860c4bf50e 100644 (file)
@@ -17,7 +17,7 @@ encode-pair Extended-Attribute-1.IP-Port-Limit-Info.Type = 1, Extended-Attribute
 match f1 0f 05 01 06 00 00 00 01 02 06 00 00 00 02
 
 decode-pair -
-match Extended-Attribute-1.IP-Port-Limit-Info = { Type = 1, Limit = 2 }
+match Extended-Attribute-1.IP-Port-Limit-Info.Type = 1, Extended-Attribute-1.IP-Port-Limit-Info.Limit = 2
 
 #
 #  And for the other attributes
@@ -26,7 +26,7 @@ encode-pair Extended-Attribute-1.IP-Port-Range.Type = 1, Extended-Attribute-1.IP
 match f1 0f 06 01 06 00 00 00 01 02 06 00 00 00 02
 
 decode-pair -
-match Extended-Attribute-1.IP-Port-Range = { Type = 1, Limit = 2 }
+match Extended-Attribute-1.IP-Port-Range.Type = 1, Extended-Attribute-1.IP-Port-Range.Limit = 2
 
 count
 match 14
index 28f5086668485f04c93f8cff318fa405bff26122..5ecb6571fd324954013cef29f4423936d103179b 100644 (file)
@@ -19,13 +19,13 @@ encode-pair Extended-Attribute-1.Unit-Ext-241-Struct2.Unit-Struct2-Int1 = 1, Ext
 match f1 1a f8 00 00 00 01 00 04 01 06 00 00 00 06 02 06 00 00 00 07 03 05 66 6f 6f
 
 decode-pair -
-match Extended-Attribute-1.Unit-Ext-241-Struct2.Unit-Struct2-Int1 = 1, Extended-Attribute-1.Unit-Ext-241-Struct2.Unit-Struct2-Short = 4, Extended-Attribute-1.Unit-Ext-241-Struct2.Unit-Struct2-TLV = { Unit-Struct2-TLV-Int1 = 6, Unit-Struct2-TLV-Int2 = 7, Unit-Struct2-TLV-String = "foo" }
+match Extended-Attribute-1.Unit-Ext-241-Struct2.Unit-Struct2-Int1 = 1, Extended-Attribute-1.Unit-Ext-241-Struct2.Unit-Struct2-Short = 4, Extended-Attribute-1.Unit-Ext-241-Struct2.Unit-Struct2-TLV.Unit-Struct2-TLV-Int1 = 6, Extended-Attribute-1.Unit-Ext-241-Struct2.Unit-Struct2-TLV.Unit-Struct2-TLV-Int2 = 7, Extended-Attribute-1.Unit-Ext-241-Struct2.Unit-Struct2-TLV.Unit-Struct2-TLV-String = "foo"
 
 encode-pair Extended-Attribute-1.Unit-Ext-241-Struct3.Unit-Struct3-Int = 1, Extended-Attribute-1.Unit-Ext-241-Struct3.Unit-Struct3-TLV.Unit-Struct3a.Unit-Struct3a-Ipaddr1 = 127.0.0.1, Extended-Attribute-1.Unit-Ext-241-Struct3.Unit-Struct3-TLV.Unit-Struct3a.Unit-Struct3a-Ipaddr2 = 8.8.8.8
 match f1 11 f9 00 00 00 01 01 0a 7f 00 00 01 08 08 08 08
 
 decode-pair -
-match Extended-Attribute-1.Unit-Ext-241-Struct3.Unit-Struct3-Int = 1, Extended-Attribute-1.Unit-Ext-241-Struct3.Unit-Struct3-TLV = { Unit-Struct3a.Unit-Struct3a-Ipaddr1 = 127.0.0.1, Unit-Struct3a.Unit-Struct3a-Ipaddr2 = 8.8.8.8 }
+match Extended-Attribute-1.Unit-Ext-241-Struct3.Unit-Struct3-Int = 1, Extended-Attribute-1.Unit-Ext-241-Struct3.Unit-Struct3-TLV.Unit-Struct3a.Unit-Struct3a-Ipaddr1 = 127.0.0.1, Extended-Attribute-1.Unit-Ext-241-Struct3.Unit-Struct3-TLV.Unit-Struct3a.Unit-Struct3a-Ipaddr2 = 8.8.8.8
 
 #
 #  Fixed size struct
index ecdaffbf8b16b22b1f1d2d14f9911b670274b72b..dde21f5bd6999fbc490a9328950ac1c8142bf6f3 100644 (file)
@@ -42,7 +42,7 @@ encode-pair Extended-Attribute-1.Unit-Ext-241-TLV.Unit-TLV-Integer = 1, Extended
 match f1 0f f3 01 06 00 00 00 01 01 06 00 00 00 02
 
 decode-pair -
-match Extended-Attribute-1.Unit-Ext-241-TLV = { Unit-TLV-Integer = 1, Unit-TLV-Integer = 2 }
+match Extended-Attribute-1.Unit-Ext-241-TLV.Unit-TLV-Integer = 1, Extended-Attribute-1.Unit-Ext-241-TLV.Unit-TLV-Integer = 2
 
 #
 #  And "long extended" EVS
@@ -77,11 +77,8 @@ encode-pair -
 match fe 08 02 06 00 00 00 05
 
 decode-pair -
-match Unit-TLV = { Delta-MSec = 5 }
+match Unit-TLV.Delta-MSec = 5
 
-#
-#  @todo - not yet converted to make nested TLVs!
-#
 attribute Unit-TLV.Delta-Sec = 10
 match Unit-TLV.Delta-Sec = 10
 
@@ -89,7 +86,7 @@ encode-pair -
 match fe 08 03 06 00 00 00 0a
 
 decode-pair -
-match Unit-TLV = { Delta-Sec = 10 }
+match Unit-TLV.Delta-Sec = 10
 
 #
 #  Allow encoding as nested VPs
index 0b7e37903b32e7d7e96427f26fa54d46f311ddaf..dda3763681089886a9b859a8d2df8ae49e2c7e47 100644 (file)
@@ -8,19 +8,19 @@ encode-pair Vendor-Specific.WiMAX.Capability.Release  = "1.0"
 match 1a 0e 00 00 60 b5 01 08 00 01 05 31 2e 30
 
 decode-pair -
-match Vendor-Specific.WiMAX.Capability = { Release = "1.0" }
+match Vendor-Specific.WiMAX.Capability.Release = "1.0"
 
 encode-pair Vendor-Specific.WiMAX.Capability.Accounting-Capabilities = 1
 match 1a 0c 00 00 60 b5 01 06 00 02 03 01
 
 decode-pair -
-match Vendor-Specific.WiMAX.Capability = { Accounting-Capabilities = IP-Session-Based }
+match Vendor-Specific.WiMAX.Capability.Accounting-Capabilities = IP-Session-Based
 
 encode-pair Vendor-Specific.WiMAX.Capability.Release = "1.0", Vendor-Specific.WiMAX.Capability.Accounting-Capabilities = 1
 match 1a 11 00 00 60 b5 01 0b 00 01 05 31 2e 30 02 03 01
 
 decode-pair -
-match Vendor-Specific.WiMAX.Capability = { Release = "1.0", Accounting-Capabilities = IP-Session-Based }
+match Vendor-Specific.WiMAX.Capability.Release = "1.0", Vendor-Specific.WiMAX.Capability.Accounting-Capabilities = IP-Session-Based
 
 encode-pair -
 match 1a 11 00 00 60 b5 01 0b 00 01 05 31 2e 30 02 03 01
@@ -87,19 +87,16 @@ encode-pair Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Direction
 match 1a 14 00 00 60 b5 54 0e 00 09 0b 04 03 01 05 06 04 04 1a 99
 
 decode-pair -
-match Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2 = { Classifier = { Direction = 1, Src-Spec = { Port = 6809 } } }
+match Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Direction = 1, Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Src-Spec.Port = 6809
 
 decode-pair 1a 11 00 00 60 b5 54 0b 00 09 08 05 06 04 04 1a 99
-match Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2 = { Classifier = { Src-Spec = { Port = 6809 } } }
-
-encode-pair -
-match 1a 11 00 00 60 b5 54 0b 00 09 08 05 06 04 04 1a 99
+match Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Src-Spec.Port = 6809
 
 # 26.24757.84.9.4 has the correct length.
 # 26.24757.84.9.5 has the correct length.
 # 26.24757.84.9.5.4 has the wrong length.
 decode-pair 1a 14 00 00 60 b5 54 0e 00 09 0b 04 03 01 05 06 04 05 1a 99
-match Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2 = { Classifier = { Direction = 1, raw.Src-Spec = 0x04051a99 } }
+match Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Direction = 1, raw.Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Src-Spec = 0x04051a99
 
 # The 26.24757.1 has the wrong length
 decode-pair 1a 11 00 00 60 b5 01 0a 00 01 05 31 2e 30 02 03 01
@@ -176,34 +173,34 @@ encode-pair Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Classifie
 match 1a 15 00 00 60 b5 54 0f 00 09 0c 09 0a 03 08 01 03 37 02 03 54
 
 decode-pair -
-match Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2 = { Classifier = { Classifier-Eth-Option = { Eth-Priority-Range = { Low = 55, High = 84 } } } }
+match Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Classifier-Eth-Option.Eth-Priority-Range.Low = 55, Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Classifier-Eth-Option.Eth-Priority-Range.High = 84
 
 #  A less efficient encoding of the above data
 decode-pair 1a 17 00 00 60 b5 54 11 00 09 0e 09 0c 03 05 01 03 37 03 05 02 03 54
-match Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2 = { Classifier = { Classifier-Eth-Option = { Eth-Priority-Range = { Low = 55 }, Eth-Priority-Range = { High = 84 } } } }
+match Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Classifier-Eth-Option.Eth-Priority-Range.Low = 55, Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Classifier-Eth-Option.Eth-Priority-Range.High = 84
 
 # 26.24757.84.9.9.3.1 has the wrong length
 decode-pair 1a 15 00 00 60 b5 54 0f 00 09 0c 09 0a 03 08 01 04 37 02 03 54
-match Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2 = { Classifier = { Classifier-Eth-Option = { raw.Eth-Priority-Range = 0x010437020354 } } }
+match raw.Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Classifier-Eth-Option.Eth-Priority-Range = 0x010437020354
 
 # 26.24757.84.9.9.3.2 has the wrong length
 decode-pair 1a 15 00 00 60 b5 54 0f 00 09 0c 09 0a 03 08 01 03 37 02 04 54
-match Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2 = { Classifier = { Classifier-Eth-Option = { raw.Eth-Priority-Range = 0x010337020454 } } }
+match raw.Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Classifier-Eth-Option.Eth-Priority-Range = 0x010337020454
 
 # 26.24757.84.9.9.3.2 has the wrong length
 # This means that the SECOND 26.24757.84.9.9.3 is invalid.
 decode-pair 1a 17 00 00 60 b5 54 11 00 09 0e 09 0c 03 05 01 03 37 03 05 02 04 54
-match Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2 = { Classifier = { Classifier-Eth-Option = { Eth-Priority-Range = { Low = 55 }, raw.Eth-Priority-Range = 0x020454 } } }
+match Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Classifier-Eth-Option.Eth-Priority-Range.Low = 55, raw.Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Classifier-Eth-Option.Eth-Priority-Range = 0x020454
 
 # 26.24757.84.9.9.3.1 has the wrong length
 # This means that 26.24757.84.9.9.3 is invalid.
 decode-pair 1a 17 00 00 60 b5 54 11 00 09 0e 09 0c 03 05 01 02 37 03 05 02 03 54
-match Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2 = { Classifier = { Classifier-Eth-Option = { raw.Eth-Priority-Range = 0x010237, Eth-Priority-Range = { High = 84 } } } }
+match raw.Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Classifier-Eth-Option.Eth-Priority-Range = 0x010237, Vendor-Specific.WiMAX.Packet-Flow-Descriptor-v2.Classifier.Classifier-Eth-Option.Eth-Priority-Range.High = 84
 #
 #  Simple test for continued attributes
 #
 decode-pair 1a 0e 00 00 60 b5 01 08 80 01 05 31 2e 30 1a 0c 00 00 60 b5 01 06 00 02 03 00
-match Vendor-Specific.WiMAX.Capability = { Release = "1.0", Accounting-Capabilities = No-Accounting }
+match Vendor-Specific.WiMAX.Capability.Release = "1.0", Vendor-Specific.WiMAX.Capability.Accounting-Capabilities = No-Accounting
 
 #
 #  See if encoding multiple attributes works
@@ -244,7 +241,7 @@ match 1a 1d 00 00 60 b5 1c 17 00 0b 14 05 12 01 06 7f 00 00 01 04 04 08 40 05 06
 #  Structs not yet decoded into sub-groups
 #
 decode-pair -
-match Vendor-Specific.WiMAX.Packet-Flow-Descriptor = { Classifier = { Src-Spec = { IP-Address = 127.0.0.1, Port = 2112, Port-Range.Start = 2112, Port-Range.End = 6809 } } }
+match Vendor-Specific.WiMAX.Packet-Flow-Descriptor.Classifier.Src-Spec.IP-Address = 127.0.0.1, Vendor-Specific.WiMAX.Packet-Flow-Descriptor.Classifier.Src-Spec.Port = 2112, Vendor-Specific.WiMAX.Packet-Flow-Descriptor.Classifier.Src-Spec.Port-Range.Start = 2112, Vendor-Specific.WiMAX.Packet-Flow-Descriptor.Classifier.Src-Spec.Port-Range.End = 6809
 
 encode-pair Vendor-Specific.WiMAX.DNS-Server = ::1
 match 1a 19 00 00 60 b5 34 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01
@@ -253,4 +250,4 @@ encode-pair Vendor-Specific.WiMAX.DNS-Server = 127.0.0.1
 match 1a 0d 00 00 60 b5 34 07 00 7f 00 00 01
 
 count
-match 118
+match 116