From d40c7623837424d4eb8048508b924887b092e050 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Mon, 19 Jun 2023 22:43:05 +0200 Subject: parser: reject zero-length interface names in flowtables Previous patch wasn't enough, also disable this for flowtable device lists. Signed-off-by: Florian Westphal --- src/parser_bison.y | 20 ++++++++++++-------- .../nft-f/zero_length_devicename_flowtable_assert | 5 +++++ 2 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 tests/shell/testcases/bogons/nft-f/zero_length_devicename_flowtable_assert diff --git a/src/parser_bison.y b/src/parser_bison.y index 9a4204c0..e7ee56c1 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -2380,17 +2380,21 @@ flowtable_list_expr : flowtable_expr_member flowtable_expr_member : QUOTED_STRING { - $$ = constant_expr_alloc(&@$, &string_type, - BYTEORDER_HOST_ENDIAN, - strlen($1) * BITS_PER_BYTE, $1); - xfree($1); + struct expr *expr = ifname_expr_alloc(&@$, state->msgs, $1); + + if (!expr) + YYERROR; + + $$ = expr; } | STRING { - $$ = constant_expr_alloc(&@$, &string_type, - BYTEORDER_HOST_ENDIAN, - strlen($1) * BITS_PER_BYTE, $1); - xfree($1); + struct expr *expr = ifname_expr_alloc(&@$, state->msgs, $1); + + if (!expr) + YYERROR; + + $$ = expr; } | variable_expr { diff --git a/tests/shell/testcases/bogons/nft-f/zero_length_devicename_flowtable_assert b/tests/shell/testcases/bogons/nft-f/zero_length_devicename_flowtable_assert new file mode 100644 index 00000000..2c3e6c3f --- /dev/null +++ b/tests/shell/testcases/bogons/nft-f/zero_length_devicename_flowtable_assert @@ -0,0 +1,5 @@ +table t { + flowtable f { + devices = { """"lo } + } +} -- cgit v1.2.3