]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: fix bogus assertion failure with boolean datatype
authorFlorian Westphal <fw@strlen.de>
Fri, 8 Dec 2023 18:38:33 +0000 (19:38 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 22 Jan 2025 23:05:48 +0000 (00:05 +0100)
commit 567937b5560fbcc7f6b74fb43c52e1cab2ac425a upstream.

The assertion is too strict, as found by afl++:

typeof iifname . ip saddr . meta ipsec
elements = { "eth0" . 10.1.1.2 . 1 }

meta ipsec is boolean (1 bit), but datasize of 1 is set at 8 bit.

Fixes: 22b750aa6dc9 ("src: allow use of base integer types as set keys in concatenations")
Signed-off-by: Florian Westphal <fw@strlen.de>
src/evaluate.c

index 849a92d15f8a45a4d273958e8a4e59b4163d60ab..669fc0e88585fd71aa13ddf2b253360e4530e2c0 100644 (file)
@@ -4452,14 +4452,15 @@ static int set_expr_evaluate_concat(struct eval_ctx *ctx, struct expr **expr)
                                                 "expressions",
                                                 i->dtype->name);
 
-               if (i->dtype->size)
-                       assert(i->len == i->dtype->size);
-
                flags &= i->flags;
 
                ntype = concat_subtype_add(ntype, i->dtype->type);
 
                dsize_bytes = div_round_up(i->len, BITS_PER_BYTE);
+
+               if (i->dtype->size)
+                       assert(dsize_bytes == div_round_up(i->dtype->size, BITS_PER_BYTE));
+
                (*expr)->field_len[(*expr)->field_count++] = dsize_bytes;
                size += netlink_padded_len(i->len);
        }