[PATCH nft 2/2] netlink_linearize: add assertion to catch for buggy byteorder

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add assertion to catch buggy bytecode where unary expression is present
with 1-byte, where no byteorder conversion is required.

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 src/netlink_linearize.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/netlink_linearize.c b/src/netlink_linearize.c
index 50dbd36c1b8e..6204d8fd2668 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)
-- 
2.30.2





[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux