From: Pablo Neira Ayuso Date: Thu, 8 Feb 2024 12:20:43 +0000 (+0100) Subject: netlink_linearize: add assertion to catch for buggy byteorder X-Git-Tag: v1.1.0~104 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8a34cca265a290a0b23cec27d5258bc432cef3d3;p=thirdparty%2Fnftables.git netlink_linearize: add assertion to catch for buggy byteorder 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 --- diff --git a/src/netlink_linearize.c b/src/netlink_linearize.c index 50dbd36c..6204d8fd 100644 --- a/src/netlink_linearize.c +++ b/src/netlink_linearize.c @@ -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)