Skip to content

Commit 0a4e1bb

Browse files
committed
update messages and fix coverity issues
1 parent 5adea1c commit 0a4e1bb

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

src/lib/unlang/xlat_expr.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3298,6 +3298,11 @@ fr_slen_t xlat_tokenize_expression(TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sb
32983298
slen = xlat_tokenize_expression_internal(ctx, out, in, p_rules, t_rules, false);
32993299
if (slen < 0) return slen;
33003300

3301+
if (!*out) {
3302+
fr_strerror_const("Empty expressions are invalid");
3303+
return -1;
3304+
}
3305+
33013306
if (xlat_finalize(*out, t_rules->xlat.runtime_el) < 0) {
33023307
TALLOC_FREE(*out);
33033308
return -1;
@@ -3314,6 +3319,11 @@ fr_slen_t xlat_tokenize_condition(TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbu
33143319
slen = xlat_tokenize_expression_internal(ctx, out, in, p_rules, t_rules, true);
33153320
if (slen < 0) return slen;
33163321

3322+
if (!*out) {
3323+
fr_strerror_const("Empty conditions are invalid");
3324+
return -1;
3325+
}
3326+
33173327
if (xlat_finalize(*out, t_rules->xlat.runtime_el) < 0) {
33183328
TALLOC_FREE(*out);
33193329
return -1;

src/lib/unlang/xlat_tokenize.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ static CC_HINT(nonnull(1,2)) int xlat_tokenize_expansion(xlat_exp_head_t *head,
751751
switch (hint) {
752752
case '}':
753753
empty_disallowed:
754-
fr_strerror_const("Empty expression is invalid");
754+
fr_strerror_const("Empty expressions are invalid");
755755
return -1;
756756

757757
case '[':

src/tests/unit/xlat/alternation.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ xlat %{ || %{User-Name}}
3939
match ERROR offset 4: Zero length attribute name: Unresolved attributes are not allowed here
4040

4141
xlat %{%{} || }
42-
match ERROR offset 5: Empty expression is invalid
42+
match ERROR offset 5: Empty expressions are invalid
4343

4444
xlat %{%{} || foo}
45-
match ERROR offset 5: Empty expression is invalid
45+
match ERROR offset 5: Empty expressions are invalid
4646

4747
xlat %{%{User-Name} ||
4848
match ERROR offset 19: Empty attribute reference

src/tests/unit/xlat/base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ xlat %{
158158
match ERROR offset 3: Missing closing brace
159159

160160
xlat %{}
161-
match ERROR offset 3: Empty expression is invalid
161+
match ERROR offset 3: Empty expressions are invalid
162162

163163
xlat %{:}
164164
match ERROR offset 3: Zero length attribute name: Unresolved attributes are not allowed here

0 commit comments

Comments
 (0)