From f14dc5810326b3e9422a127710ef9e13886d5d2d Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Tue, 10 Jun 2014 10:28:21 -0400 Subject: [PATCH] Redundant, load-balance, etc. can't be empty --- src/main/modcall.c | 23 ++++++++++++++++++++++- src/tests/keywords/redundant-error | 6 ++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/tests/keywords/redundant-error diff --git a/src/main/modcall.c b/src/main/modcall.c index 3aee518..701e22e 100644 --- a/src/main/modcall.c +++ b/src/main/modcall.c @@ -899,6 +899,8 @@ redo: g = mod_callabletogroup(c); found = NULL; + rad_assert(g->children != NULL); + for (this = g->children; this; this = this->next) { if (!found) { found = this; @@ -2503,7 +2505,8 @@ static modcallable *do_compile_modgroup(modcallable *parent, c->name = cf_section_name2(cs); if (!c->name) { c->name = cf_section_name1(cs); - if (strcmp(c->name, "group") == 0) { + if ((strcmp(c->name, "group") == 0) || + (strcmp(c->name, "redundant") == 0)) { c->name = ""; } else if (c->type == MOD_GROUP) { c->type = MOD_POLICY; @@ -2678,6 +2681,24 @@ set_codes: } } + switch (c->type) { + default: + break; + + case MOD_GROUP: + if (grouptype != GROUPTYPE_REDUNDANT) break; + /* FALL-THROUGH */ + + case MOD_LOAD_BALANCE: + case MOD_REDUNDANT_LOAD_BALANCE: + if (!g->children) { + cf_log_err_cs(g->cs, "%s sections cannot be empty", + cf_section_name1(g->cs)); + modcallable_free(&c); + return NULL; + } + } + /* * FIXME: If there are no children, return NULL? */ diff --git a/src/tests/keywords/redundant-error b/src/tests/keywords/redundant-error new file mode 100644 index 0000000..bec4335 --- /dev/null +++ b/src/tests/keywords/redundant-error @@ -0,0 +1,6 @@ +# +# Check that redundant blocks can't be empty +# +redundant { # ERROR + +} -- 2.1.4