From: Alan T. DeKok Date: Wed, 20 Feb 2019 02:00:35 +0000 (-0500) Subject: disallow nested statements X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc955ddafa13ca99cd008e3aaff9093e47d14133;p=thirdparty%2Ffreeradius-server.git disallow nested statements i.e. "host" inside of "host" except for "group", which is fine... --- diff --git a/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c b/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c index e3fdb47e834..1fc96f6cdbe 100644 --- a/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c +++ b/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c @@ -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 */