]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
more stringent checks on references
authorAlan T. DeKok <aland@freeradius.org>
Mon, 25 May 2026 17:28:56 +0000 (13:28 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 25 May 2026 17:28:56 +0000 (13:28 -0400)
we can't refer to any parent, otherwise we end up copying ourselves

src/lib/server/cf_file.c

index 76f001b7bb348619e8a59e967733b4774fc34dd9..f15dcd15946852354f1e5e30634f32c1af5259c6 100644 (file)
@@ -366,15 +366,16 @@ char const *cf_expand_variables(char const *cf, int lineno,
 
                        } else if (ci->type == CONF_ITEM_SECTION) {
                                CONF_SECTION *subcs;
+                               CONF_ITEM *ci_p;
 
                                /*
-                                *      Adding an entry again to a
-                                *      section is wrong.  We don't
-                                *      want an infinite loop.
+                                *      We can't refer to any parent, otherwise we have an infinite loop.
                                 */
-                               if (cf_item_to_section(ci->parent) == outer_cs) {
-                                       ERROR("%s[%d]: Cannot reference different item in same section", cf, lineno);
-                                       return NULL;
+                               for (ci_p = &outer_cs->item; ci_p != NULL; ci_p = ci_p->parent) {
+                                       if (ci_p == ci) {
+                                               ERROR("%s[%d]: Cannot reference different item in same section", cf, lineno);
+                                               return NULL;
+                                       }
                                }
 
                                /*