]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
ct: Fix ct label value parser
authorPhil Sutter <phil@nwl.cc>
Wed, 10 Mar 2021 15:56:11 +0000 (16:56 +0100)
committerPhil Sutter <phil@nwl.cc>
Tue, 30 Nov 2021 13:57:46 +0000 (14:57 +0100)
Size of array to export the bit value into was eight times too large, so
on Big Endian the data written into the data reg was always zero.

Fixes: 2fcce8b0677b3 ("ct: connlabel matching support")
Signed-off-by: Phil Sutter <phil@nwl.cc>
src/ct.c

index 2218ecc7a684d1e0193cf0e2566f40f361cfae9e..6049157198ad9b437648b53cf35e51bebf51a1e4 100644 (file)
--- a/src/ct.c
+++ b/src/ct.c
@@ -176,7 +176,7 @@ static struct error_record *ct_label_type_parse(struct parse_ctx *ctx,
 {
        const struct symbolic_constant *s;
        const struct datatype *dtype;
-       uint8_t data[CT_LABEL_BIT_SIZE];
+       uint8_t data[CT_LABEL_BIT_SIZE / BITS_PER_BYTE];
        uint64_t bit;
        mpz_t value;
 
@@ -211,8 +211,7 @@ static struct error_record *ct_label_type_parse(struct parse_ctx *ctx,
        mpz_export_data(data, value, BYTEORDER_HOST_ENDIAN, sizeof(data));
 
        *res = constant_expr_alloc(&sym->location, dtype,
-                                  dtype->byteorder, sizeof(data),
-                                  data);
+                                  dtype->byteorder, CT_LABEL_BIT_SIZE, data);
        mpz_clear(value);
        return NULL;
 }