]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
fix case where the section already exists
authorAlan T. DeKok <aland@freeradius.org>
Fri, 27 Jun 2025 15:49:04 +0000 (11:49 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 27 Jun 2025 18:02:31 +0000 (14:02 -0400)
and check for dups

src/lib/server/cf_file.c

index 1bf5826696fe7a04a4cbc1be8333bce100024985..56cf679913ea68a6891100da2178002ee4b950bf 100644 (file)
@@ -2529,6 +2529,19 @@ alloc_section:
                                ERROR("%s[%d]: Reference \"%s\" is not a section", frame->filename, frame->lineno, name);
                                return -1;
                        }
+
+                       /*
+                        *      Set the new parent and ensure we're
+                        *      not creating a duplicate section.
+                        */
+                       parent = cf_item_to_section(ci);
+                       css = cf_section_find(parent, value, NULL);
+                       if (css) {
+                               ERROR("%s[%d]: Reference \"%s\" already contains a \"%s\" section at %s[%d]",
+                                     frame->filename, frame->lineno, name, value,
+                                     css->item.filename, css->item.lineno);
+                               return -1;
+                       }
                }
 
                frame->at_reference = frame->current;