From 5731cc15d3929312c5b63206c8a8a06fb8ce6bab Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Fri, 13 Sep 2019 17:20:04 +0200 Subject: parser_bison: Fix 'exists' keyword on Big Endian Size value passed to constant_expr_alloc() must correspond with actual data size, otherwise wrong portion of data will be taken later when serializing into netlink message. Booleans require really just a bit, but make type of boolean_keys be uint8_t (introducing new 'val8' name for it) and pass the data length using sizeof() to avoid any magic numbers. While being at it, fix len value in parser_json.c as well although it worked before due to the value being rounded up to the next multiple of 8. Fixes: 9fd9baba43c8e ("Introduce boolean datatype and boolean expression") Signed-off-by: Phil Sutter Acked-by: Florian Westphal --- src/parser_bison.y | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/parser_bison.y') diff --git a/src/parser_bison.y b/src/parser_bison.y index 3fccea67..cd249c82 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -135,6 +135,7 @@ int nft_lex(void *, void *, void *); %union { uint64_t val; uint32_t val32; + uint8_t val8; const char * string; struct list_head *list; @@ -800,7 +801,7 @@ int nft_lex(void *, void *, void *); %type boolean_expr %destructor { expr_free($$); } boolean_expr -%type boolean_keys +%type boolean_keys %type exthdr_exists_expr %destructor { expr_free($$); } exthdr_exists_expr @@ -3964,7 +3965,7 @@ boolean_expr : boolean_keys { $$ = constant_expr_alloc(&@$, &boolean_type, BYTEORDER_HOST_ENDIAN, - 1, &$1); + sizeof($1) * BITS_PER_BYTE, &$1); } ; -- cgit v1.2.3