]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: explicitly deny concatenated types in interval sets
authorPhil Sutter <phil@nwl.cc>
Wed, 6 Jun 2018 11:21:49 +0000 (13:21 +0200)
committerFlorian Westphal <fw@strlen.de>
Wed, 6 Jun 2018 12:17:56 +0000 (14:17 +0200)
Previously, this triggered a program abort:

| # nft add table ip t
| # nft add set ip t my_set '{ type ipv4_addr . inet_service ; flags interval ; }'
| # nft add element ip t my_set '{10.0.0.1 . tcp }'
| BUG: invalid range expression type concat
| nft: expression.c:1085: range_expr_value_low: Assertion `0' failed.

With this patch in place, the 'add set' command above gives an error
message:

| # nft add set ip t my_set3 '{ type ipv4_addr . inet_service ; flags interval ; }'
| Error: concatenated types not supported in interval sets
| add set ip t my_set3 { type ipv4_addr . inet_service ; flags interval ; }
|                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
src/evaluate.c

index 33733c0e73075ae2a4680198fbf198dc1fba4897..22b14c972d930a55c996154cd12eca5273ee1221 100644 (file)
@@ -2801,6 +2801,10 @@ static int set_evaluate(struct eval_ctx *ctx, struct set *set)
                                         "specified in %s definition",
                                         set->key->dtype->name, type);
        }
+       if (set->flags & NFT_SET_INTERVAL &&
+           set->key->ops->type == EXPR_CONCAT)
+               return set_error(ctx, set, "concatenated types not supported in interval sets");
+
        if (set->flags & NFT_SET_MAP) {
                if (set->datatype == NULL)
                        return set_error(ctx, set, "map definition does not "