]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: error out when expression has no datatype
authorFlorian Westphal <fw@strlen.de>
Thu, 11 Jan 2024 15:57:28 +0000 (16:57 +0100)
committerFlorian Westphal <fw@strlen.de>
Thu, 11 Jan 2024 17:25:55 +0000 (18:25 +0100)
add rule ip6 f i rt2 addr . ip6 daddr  { dead:: . dead:: }

... will cause a segmentation fault, we assume expr->dtype is always
set.

rt2 support is incomplete, the template is uninitialised.

This could be fixed up, but rt2 (a subset of the deperecated type 0),
like all other routing headers, lacks correct dependency tracking.

Currently such routing headers are always assumed to be segment routing
headers, we would need to add dependency on 'Routing Type' field in the
routing header, similar to icmp type/code.

Signed-off-by: Florian Westphal <fw@strlen.de>
src/evaluate.c

index 41524eef12b7cffd0028c1e3e8a6a232a3194a88..197c82c2eaf9282a318920bd6c938c9e2e446157 100644 (file)
@@ -1593,6 +1593,11 @@ static int expr_evaluate_concat(struct eval_ctx *ctx, struct expr **expr)
                                          "cannot use %s in concatenation",
                                          expr_name(i));
 
+               if (!i->dtype)
+                       return expr_error(ctx->msgs, i,
+                                         "cannot use %s in concatenation, lacks datatype",
+                                         expr_name(i));
+
                flags &= i->flags;
 
                if (!key && i->dtype->type == TYPE_INTEGER) {