]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
disallow nested statements
authorAlan T. DeKok <aland@freeradius.org>
Wed, 20 Feb 2019 02:00:35 +0000 (21:00 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 20 Feb 2019 02:00:35 +0000 (21:00 -0500)
i.e. "host" inside of "host"

except for "group", which is fine...

src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c

index e3fdb47e8345d1621240ee3ab89b007bba845dbb..1fc96f6cdbe584a684cd098f3a8bf06019dd0898 100644 (file)
@@ -1143,6 +1143,33 @@ static int parse_section(rlm_isc_dhcp_tokenizer_t *state, rlm_isc_dhcp_info_t *i
        int rcode;
        int entries = 0;
 
+       /*
+        *      We don't allow "host" inside of "host", even with
+        *      multiple layers of nesting.  The same rules apply to
+        *      every section except "group".
+        */
+       if (strncmp(info->cmd->name, "group", 5) != 0) {
+               rlm_isc_dhcp_info_t *parent;
+
+               for (parent = info->parent; parent != NULL; parent = parent->parent) {
+                       char const *q;
+
+                       if (!parent->cmd) break; /* top level */
+
+                       if (parent->cmd != info->cmd) continue;
+
+                       /*
+                        *      Be gentle to the end user
+                        */
+                       q = parent->cmd->name;
+                       while (*q && !isspace((int) *q)) q++;
+
+                       fr_strerror_printf("cannot nest '%.*s' statements",
+                                          (int) (q - parent->cmd->name), parent->cmd->name);
+                       return -1;
+               }
+       }
+
        IDEBUG("%.*s {", state->braces - 1, spaces); /* "braces" was already incremented */
        state->allow_eof = false; /* can't have EOF in the middle of a section */