diff mbox series

[nft,04/15] src: Fix payload statement mask on Big Endian

Message ID 20211124172251.11539-5-phil@nwl.cc
State Accepted
Delegated to: Pablo Neira
Headers show
Series Fix netlink debug output on Big Endian | expand

Commit Message

Phil Sutter Nov. 24, 2021, 5:22 p.m. UTC
The mask used to select bits to keep must be exported in the same
byteorder as the payload statement itself, also the length of the
exported data must match the number of bytes extracted earlier.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/evaluate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/evaluate.c b/src/evaluate.c
index eebd992159a11..49fb8f84fe76b 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -2556,9 +2556,9 @@  static int stmt_evaluate_payload(struct eval_ctx *ctx, struct stmt *stmt)
 	mpz_clear(ff);
 
 	assert(sizeof(data) * BITS_PER_BYTE >= masklen);
-	mpz_export_data(data, bitmask, BYTEORDER_HOST_ENDIAN, sizeof(data));
+	mpz_export_data(data, bitmask, payload->byteorder, payload_byte_size);
 	mask = constant_expr_alloc(&payload->location, expr_basetype(payload),
-				   BYTEORDER_HOST_ENDIAN, masklen, data);
+				   payload->byteorder, masklen, data);
 	mpz_clear(bitmask);
 
 	payload_bytes = payload_expr_alloc(&payload->location, NULL, 0);