From: Alan T. DeKok Date: Thu, 5 Sep 2024 15:45:02 +0000 (-0400) Subject: catch more corner cases of bare words in "case" for non-& X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=beb30ee0cdd99f0dd719700486e8001533ae01bc;p=thirdparty%2Ffreeradius-server.git catch more corner cases of bare words in "case" for non-& --- diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index f23823a3cbc..2ba29f285f7 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -2979,7 +2979,8 @@ static unlang_t *compile_case(unlang_t *parent, unlang_compile_t *unlang_ctx, CO /* * Bare word strings are attribute references when tmpl_require_enum_prefix=yes */ - if (tmpl_is_attr(vpt)) { + if (tmpl_is_attr(vpt) || tmpl_is_attr_unresolved(vpt)) { + fail_attr: cf_log_err(cs, "arguments to 'case' statements MUST NOT be attribute references."); goto fail; } @@ -2990,6 +2991,15 @@ static unlang_t *compile_case(unlang_t *parent, unlang_compile_t *unlang_ctx, CO talloc_free(vpt); return NULL; } + + /* + * When tmpl_require_enum_prefix=yes, references to unresolved attributes + * are instead compiled as "bare word" strings. Which we now forbid. + */ + if (tmpl_require_enum_prefix && (quote == T_BARE_WORD) && (tmpl_value_type(vpt) == FR_TYPE_STRING)) { + goto fail_attr; + } + } /* else it's a default 'case' statement */ /*