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.0.6.1~241 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=55cdfc7cf710033cc844206437bfcbd62070035d;p=thirdparty%2Fnftables.git netlink_linearize: add assertion to catch for buggy byteorder commit 8a34cca265a290a0b23cec27d5258bc432cef3d3 upstream. 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 c2cb4f73..15275402 100644 --- a/src/netlink_linearize.c +++ b/src/netlink_linearize.c @@ -725,6 +725,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)