]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
netlink_linearize: add assertion to catch for buggy byteorder
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 8 Feb 2024 12:20:43 +0000 (13:20 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 9 Feb 2024 15:56:04 +0000 (16:56 +0100)
Add assertion to catch buggy bytecode where unary expression is present
with 1-byte selectors, where no byteorder conversion is required.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/netlink_linearize.c

index 50dbd36c1b8ea1ed6c895f6028e77c43971bc933..6204d8fd26681142e2c469aebd5aba9251b6b3f2 100644 (file)
@@ -797,6 +797,8 @@ static void netlink_gen_unary(struct netlink_linearize_ctx *ctx,
        struct nftnl_expr *nle;
        int byte_size;
 
+       assert(div_round_up(expr->arg->len, BITS_PER_BYTE) != 1);
+
        if ((expr->arg->len % 64) == 0)
                byte_size = 8;
        else if ((expr->arg->len % 32) == 0)