From: Alan T. DeKok Date: Tue, 18 Mar 2025 02:58:33 +0000 (+0700) Subject: update messages and fix coverity issues X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a4e1bb80cc2cf82a89fa5ee0e5db716c182403b;p=thirdparty%2Ffreeradius-server.git update messages and fix coverity issues --- diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index 75ebc139060..2a530461345 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -3298,6 +3298,11 @@ fr_slen_t xlat_tokenize_expression(TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sb slen = xlat_tokenize_expression_internal(ctx, out, in, p_rules, t_rules, false); if (slen < 0) return slen; + if (!*out) { + fr_strerror_const("Empty expressions are invalid"); + return -1; + } + if (xlat_finalize(*out, t_rules->xlat.runtime_el) < 0) { TALLOC_FREE(*out); return -1; @@ -3314,6 +3319,11 @@ fr_slen_t xlat_tokenize_condition(TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbu slen = xlat_tokenize_expression_internal(ctx, out, in, p_rules, t_rules, true); if (slen < 0) return slen; + if (!*out) { + fr_strerror_const("Empty conditions are invalid"); + return -1; + } + if (xlat_finalize(*out, t_rules->xlat.runtime_el) < 0) { TALLOC_FREE(*out); return -1; diff --git a/src/lib/unlang/xlat_tokenize.c b/src/lib/unlang/xlat_tokenize.c index aec56b91802..b6c6195221e 100644 --- a/src/lib/unlang/xlat_tokenize.c +++ b/src/lib/unlang/xlat_tokenize.c @@ -751,7 +751,7 @@ check_for_attr: switch (hint) { case '}': empty_disallowed: - fr_strerror_const("Empty expression is invalid"); + fr_strerror_const("Empty expressions are invalid"); return -1; case '[': diff --git a/src/tests/unit/xlat/alternation.txt b/src/tests/unit/xlat/alternation.txt index 2772c5d3c73..83c93c4d0f8 100644 --- a/src/tests/unit/xlat/alternation.txt +++ b/src/tests/unit/xlat/alternation.txt @@ -39,10 +39,10 @@ xlat %{ || %{User-Name}} match ERROR offset 4: Zero length attribute name: Unresolved attributes are not allowed here xlat %{%{} || } -match ERROR offset 5: Empty expression is invalid +match ERROR offset 5: Empty expressions are invalid xlat %{%{} || foo} -match ERROR offset 5: Empty expression is invalid +match ERROR offset 5: Empty expressions are invalid xlat %{%{User-Name} || match ERROR offset 19: Empty attribute reference diff --git a/src/tests/unit/xlat/base.txt b/src/tests/unit/xlat/base.txt index 95f62d45747..ce134816fbd 100644 --- a/src/tests/unit/xlat/base.txt +++ b/src/tests/unit/xlat/base.txt @@ -158,7 +158,7 @@ xlat %{ match ERROR offset 3: Missing closing brace xlat %{} -match ERROR offset 3: Empty expression is invalid +match ERROR offset 3: Empty expressions are invalid xlat %{:} match ERROR offset 3: Zero length attribute name: Unresolved attributes are not allowed here