]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: Fix payload statement mask on Big Endian
authorPhil Sutter <phil@nwl.cc>
Thu, 17 Dec 2020 17:19:18 +0000 (18:19 +0100)
committerPhil Sutter <phil@nwl.cc>
Tue, 30 Nov 2021 13:57:46 +0000 (14:57 +0100)
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

index eebd992159a117cdf4bd51d253b6cc9bd46b5074..49fb8f84fe76b58ba0351682971ba531c5e9d291 100644 (file)
@@ -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);