Skip to content

Commit

Permalink
case statements can't refer to lists
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Jan 20, 2015
1 parent 1b7be47 commit 49e4d89
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/modcall.c
Expand Up @@ -1961,6 +1961,22 @@ static modcallable *do_compile_modcase(modcallable *parent, rlm_components_t com
return NULL;
}

/*
* Only certain things are allowed...
*/
switch (vpt->type) {
case TMPL_TYPE_LITERAL:
case TMPL_TYPE_XLAT:
case TMPL_TYPE_ATTR:
case TMPL_TYPE_REGEX:
case TMPL_TYPE_EXEC:
break;

default:
cf_log_err_cs(cs, "Syntax error: Cannot match '%s'", name2);
return NULL;
}

/*
* Otherwise a NULL vpt may refer to an attribute defined
* by a module. That is checked in pass 2.
Expand Down
19 changes: 19 additions & 0 deletions src/tests/keywords/case-list
@@ -0,0 +1,19 @@
switch &User-Name {
case "bob" {
update reply {
Filter-Id := "filter"
}
}

case &reply: { # ERROR
update reply {
Filter-Id := "doug"
}
}

case {
update reply {
Filter-Id := "default"
}
}
}

0 comments on commit 49e4d89

Please sign in to comment.