* [PATCH nft] parser_bison: error out on duplicated type/typeof/element keywords
@ 2023-12-19 15:22 Florian Westphal
0 siblings, 0 replies; only message in thread
From: Florian Westphal @ 2023-12-19 15:22 UTC (permalink / raw)
To: netfilter-devel; +Cc: Florian Westphal
Otherwise nft will leak the previous definition (expressions).
Also remove the nonsensical
datatype_set($1->key, $3->dtype);
This is a no-op, at this point: $1->key and $3 are identical.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
src/parser_bison.y | 38 ++++++++++++++++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/src/parser_bison.y b/src/parser_bison.y
index 8f4182c9b296..86fb9f077db8 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -2174,11 +2174,20 @@ set_block : /* empty */ { $$ = $<set>-1; }
| set_block stmt_separator
| set_block TYPE data_type_expr stmt_separator close_scope_type
{
+ if (already_set($1->key, &@2, state)) {
+ expr_free($3);
+ YYERROR;
+ }
+
$1->key = $3;
$$ = $1;
}
| set_block TYPEOF typeof_expr stmt_separator
{
+ if (already_set($1->key, &@2, state)) {
+ expr_free($3);
+ YYERROR;
+ }
$1->key = $3;
datatype_set($1->key, $3->dtype);
$$ = $1;
@@ -2206,6 +2215,10 @@ set_block : /* empty */ { $$ = $<set>-1; }
}
| set_block ELEMENTS '=' set_block_expr
{
+ if (already_set($1->init, &@2, state)) {
+ expr_free($4);
+ YYERROR;
+ }
$1->init = $4;
$$ = $1;
}
@@ -2277,6 +2290,12 @@ map_block : /* empty */ { $$ = $<set>-1; }
data_type_expr COLON map_block_data_interval data_type_expr
stmt_separator close_scope_type
{
+ if (already_set($1->key, &@2, state)) {
+ expr_free($3);
+ expr_free($6);
+ YYERROR;
+ }
+
$1->key = $3;
$1->data = $6;
$1->data->flags |= $5;
@@ -2288,8 +2307,13 @@ map_block : /* empty */ { $$ = $<set>-1; }
typeof_expr COLON typeof_data_expr
stmt_separator
{
+ if (already_set($1->key, &@2, state)) {
+ expr_free($3);
+ expr_free($5);
+ YYERROR;
+ }
+
$1->key = $3;
- datatype_set($1->key, $3->dtype);
$1->data = $5;
$1->flags |= NFT_SET_MAP;
@@ -2299,8 +2323,13 @@ map_block : /* empty */ { $$ = $<set>-1; }
typeof_expr COLON INTERVAL typeof_expr
stmt_separator
{
+ if (already_set($1->key, &@2, state)) {
+ expr_free($3);
+ expr_free($6);
+ YYERROR;
+ }
+
$1->key = $3;
- datatype_set($1->key, $3->dtype);
$1->data = $6;
$1->data->flags |= EXPR_F_INTERVAL;
@@ -2311,6 +2340,11 @@ map_block : /* empty */ { $$ = $<set>-1; }
data_type_expr COLON map_block_obj_type
stmt_separator close_scope_type
{
+ if (already_set($1->key, &@2, state)) {
+ expr_free($3);
+ YYERROR;
+ }
+
$1->key = $3;
$1->objtype = $5;
$1->flags |= NFT_SET_OBJECT;
--
2.41.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-12-19 15:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-19 15:22 [PATCH nft] parser_bison: error out on duplicated type/typeof/element keywords Florian Westphal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox