Skip to contentSkip to conversation

parser_bison: fix memleak in meta set error handling

PATCH New Florian Westphal 1 participant 1 message Dec 8, 2023 netfilter

lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 parser_bison: fix memleak in meta set error handling

We must release the expression here, found via afl++ and -fsanitize-address build.

---
 src/parser_bison.y                                           | 1 +
 .../shell/testcases/bogons/nft-f/memleak_on_meta_set_errpath | 5 +++++
 2 files changed, 6 insertions(+)
 create mode 100644 tests/shell/testcases/bogons/nft-f/memleak_on_meta_set_errpath
src/parser_bison.y +1 -0
index 3e0f08b22c44..91c4d263dc73 100644
@@ -5338,6 +5338,7 @@ meta_stmt		:	META	meta_key	SET	stmt_expr	close_scope_meta
 				free_const($2);
 				if (erec != NULL) {
 					erec_queue(erec, state->msgs);
+					expr_free($4);
 					YYERROR;
 				}
 
tests/shell/testcases/bogons/nft-f/memleak_on_meta_set_errpath new file +5 -0
new file mode 100644
index 000000000000..917e8bf83f6a
@@ -0,0 +1,5 @@
+table filter {
+ chain y {
+  meta seccark set ct secmark
+ }
+}
Signature · 1 line
2.41.0