From 15c39ac1f6924e51f0715de4266a5f1a3b9f31fc Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Thu, 17 Dec 2020 18:19:18 +0100 Subject: src: Fix payload statement mask on Big Endian 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 --- src/evaluate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/evaluate.c') diff --git a/src/evaluate.c b/src/evaluate.c index eebd9921..49fb8f84 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); -- cgit v1.2.3