]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: parser_bison: prevent multiple ip daddr/saddr definitions
authorFlorian Westphal <fw@strlen.de>
Thu, 16 Oct 2025 14:59:35 +0000 (16:59 +0200)
committerFlorian Westphal <fw@strlen.de>
Fri, 17 Oct 2025 07:41:51 +0000 (09:41 +0200)
minor change to the bogon makes it assert because symbolic expression
will have wrong refcount (2) at scope teardown.

Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Fernando Fernandez Mancera <fmancera@suse.de>
src/parser_bison.y
tests/shell/testcases/bogons/nft-f/tunnel_with_anon_set_assert

index b63c7df18a35e408e4260c5ccce02ff9693d3658..4e028d31c165fbb9f0743d15ac318e9f4996a6c5 100644 (file)
@@ -5070,21 +5070,38 @@ tunnel_config           :       ID      NUM
                        }
                        |       IP      SADDR   symbol_expr     close_scope_ip
                        {
+                               if (already_set($<obj>0->tunnel.src, &@3, state)) {
+                                       expr_free($3);
+                                       YYERROR;
+                               }
+
                                $<obj>0->tunnel.src = $3;
                                datatype_set($3, &ipaddr_type);
                        }
                        |       IP      DADDR   symbol_expr     close_scope_ip
                        {
+                               if (already_set($<obj>0->tunnel.dst, &@3, state)) {
+                                       expr_free($3);
+                                       YYERROR;
+                               }
                                $<obj>0->tunnel.dst = $3;
                                datatype_set($3, &ipaddr_type);
                        }
                        |       IP6     SADDR   symbol_expr     close_scope_ip6
                        {
+                               if (already_set($<obj>0->tunnel.src, &@3, state)) {
+                                       expr_free($3);
+                                       YYERROR;
+                               }
                                $<obj>0->tunnel.src = $3;
                                datatype_set($3, &ip6addr_type);
                        }
                        |       IP6     DADDR   symbol_expr     close_scope_ip6
                        {
+                               if (already_set($<obj>0->tunnel.dst, &@3, state)) {
+                                       expr_free($3);
+                                       YYERROR;
+                               }
                                $<obj>0->tunnel.dst = $3;
                                datatype_set($3, &ip6addr_type);
                        }
index 6f7b212aefefaacc65985c07c2177c11ab009dea..d025689443010f178d69700f527865e8b13367e7 100644 (file)
@@ -3,6 +3,7 @@ define s = { 1.2.3.4, 5.6.7.8 }
 table netdev x {
        tunnel t {
                ip saddr $s
+               ip saddr $s
        }
        }