diff options
| author | Florian Westphal <fw@strlen.de> | 2025-07-21 13:09:55 +0200 |
|---|---|---|
| committer | Florian Westphal <fw@strlen.de> | 2025-07-22 14:38:34 +0200 |
| commit | f4d3e5e2f6595b6628b2aa948ff45ffaec40fb65 (patch) | |
| tree | 7bec1c70367e182f0132a6ca61470098b5159194 /src/parser_json.c | |
| parent | bc1eeb8fe709b2c0322a6b0e447517256cc9c18b (diff) | |
parser_json: reject non-concat expression
Before "src: detach set, list and concatenation expression layout":
internal:0:0-0: Error: Concatenation with 0 elements is illegal
After this change, expr->size access triggers assert() failure, add
explicit test for etype to avoid this and error out:
internal:0:0-0: Error: Expected concat element, got symbol.
Fixes: e0d92243be1c ("src: detach set, list and concatenation expression layout")
Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/parser_json.c')
| -rw-r--r-- | src/parser_json.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/parser_json.c b/src/parser_json.c index bd865de5..a6f142c6 100644 --- a/src/parser_json.c +++ b/src/parser_json.c @@ -1286,11 +1286,18 @@ static struct expr *json_parse_binop_expr(struct json_ctx *ctx, static struct expr *json_check_concat_expr(struct json_ctx *ctx, struct expr *e) { + if (e->etype != EXPR_CONCAT) { + json_error(ctx, "Expected concatenation, got %s", expr_name(e)); + goto err_free; + } + if (expr_concat(e)->size >= 2) return e; json_error(ctx, "Concatenation with %d elements is illegal", expr_concat(e)->size); + +err_free: expr_free(e); return NULL; } |
