From: Pablo Neira Ayuso Date: Thu, 6 Jul 2023 08:26:39 +0000 (+0200) Subject: netlink_linearize: use div_round_up in byteorder length X-Git-Tag: v1.0.6.1~186 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3a98450308550e7c64fc39c1e21b0cf3f50d786f;p=thirdparty%2Fnftables.git netlink_linearize: use div_round_up in byteorder length commit 25e7b99cc450490c38becb03d8bddd0199cfd3f9 upstream. Use div_round_up() to calculate the byteorder length, otherwise fields that take % BITS_PER_BYTE != 0 are not considered by the byteorder expression. Reported-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso --- diff --git a/src/netlink_linearize.c b/src/netlink_linearize.c index 527f3fc5..1aaa1284 100644 --- a/src/netlink_linearize.c +++ b/src/netlink_linearize.c @@ -740,7 +740,7 @@ static void netlink_gen_unary(struct netlink_linearize_ctx *ctx, netlink_put_register(nle, NFTNL_EXPR_BYTEORDER_SREG, dreg); netlink_put_register(nle, NFTNL_EXPR_BYTEORDER_DREG, dreg); nftnl_expr_set_u32(nle, NFTNL_EXPR_BYTEORDER_LEN, - expr->len / BITS_PER_BYTE); + div_round_up(expr->len, BITS_PER_BYTE)); nftnl_expr_set_u32(nle, NFTNL_EXPR_BYTEORDER_SIZE, byte_size); nftnl_expr_set_u32(nle, NFTNL_EXPR_BYTEORDER_OP,