]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
one more case of fill in attribute ref for aliases
authorAlan T. DeKok <aland@freeradius.org>
Wed, 4 Oct 2023 15:10:00 +0000 (11:10 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 4 Oct 2023 15:10:00 +0000 (11:10 -0400)
src/lib/server/tmpl_tokenize.c
src/tests/keywords/alias [new file with mode: 0644]

index 59d5eeb08c17b14740e7f697aaf11e1c99ed0b79..3f9c851393a755a1949c281dede417787da698d8 100644 (file)
@@ -1579,13 +1579,13 @@ fr_slen_t tmpl_attr_ref_afrom_unresolved_substr(TALLOC_CTX *ctx, tmpl_attr_error
  *     Add attr_ref when we've parsed an intermediate dictionary name
  *     which is itself a ref.
  */
-static void tmpl_attr_ref_fixup(TALLOC_CTX *ctx, tmpl_t *vpt, fr_dict_attr_t const *da)
+static void tmpl_attr_ref_fixup(TALLOC_CTX *ctx, tmpl_t *vpt, fr_dict_attr_t const *da, fr_dict_attr_t const *parent)
 {
        tmpl_attr_t *ar;
 
        if (tmpl_attr_tail_da(vpt) == da) return;
 
-       if (!da->parent->flags.is_root) tmpl_attr_ref_fixup(ctx, vpt, da->parent);
+       if (da->parent != parent) tmpl_attr_ref_fixup(ctx, vpt, da->parent, parent);
 
        MEM(ar = talloc(ctx, tmpl_attr_t));
        *ar = (tmpl_attr_t) {
@@ -1687,7 +1687,7 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t
                        our_parent = da->parent;
 
                        if (!our_parent->flags.is_root) {
-                               tmpl_attr_ref_fixup(ctx, vpt, our_parent);
+                               tmpl_attr_ref_fixup(ctx, vpt, our_parent, fr_dict_root(da->dict));
                        }
                }
        } else {
@@ -1757,6 +1757,10 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t
                 */
                fr_assert(our_parent != NULL);
 
+               if (da->parent != our_parent) {
+                       tmpl_attr_ref_fixup(ctx, vpt, da->parent, our_parent);
+               }
+
                goto alloc_ar;
        }
 
@@ -1799,7 +1803,7 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t
                 *      reference.
                 */
                da = fr_dict_attr_child_by_num(namespace, oid);
-               if (da) goto  alloc_ar;
+               if (da) goto alloc_ar;
 
                if (!at_rules->allow_unknown) {
                disallow_unknown:
diff --git a/src/tests/keywords/alias b/src/tests/keywords/alias
new file mode 100644 (file)
index 0000000..6844c22
--- /dev/null
@@ -0,0 +1,10 @@
+&Vendor-Specific.WiMAX.Capability.Release := "foo"
+
+#
+#  WiMAX is an alias to Vendor-Specific.WiMAX
+#
+if !(&request.WiMAX.Capability.Release == "foo") {
+       test_fail
+}
+
+success