|
 |
ad45ff |
From 56d8528fdd3c3f7db138622d94d2a6bac6b46e4e Mon Sep 17 00:00:00 2001
|
|
 |
ad45ff |
From: Phil Sutter <psutter@redhat.com>
|
|
 |
ad45ff |
Date: Wed, 20 Jun 2018 09:22:47 +0200
|
|
 |
ad45ff |
Subject: [PATCH] evaluate: Fix memleak in stmt_reject_gen_dependency()
|
|
 |
ad45ff |
|
|
 |
ad45ff |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1504157
|
|
 |
ad45ff |
Upstream Status: nftables commit edcf3adcf4c4c
|
|
 |
ad45ff |
|
|
 |
ad45ff |
commit edcf3adcf4c4cf58cb0b965b984a512b12181a58
|
|
 |
ad45ff |
Author: Phil Sutter <phil@nwl.cc>
|
|
 |
ad45ff |
Date: Thu Mar 1 15:00:29 2018 +0100
|
|
 |
ad45ff |
|
|
 |
ad45ff |
evaluate: Fix memleak in stmt_reject_gen_dependency()
|
|
 |
ad45ff |
|
|
 |
ad45ff |
The allocated payload expression is not used after returning from that
|
|
 |
ad45ff |
function, so it needs to be freed again.
|
|
 |
ad45ff |
|
|
 |
ad45ff |
Simple test case:
|
|
 |
ad45ff |
|
|
 |
ad45ff |
| nft add rule inet t c reject with tcp reset
|
|
 |
ad45ff |
|
|
 |
ad45ff |
Valgrind reports definitely lost 144 bytes.
|
|
 |
ad45ff |
|
|
 |
ad45ff |
Signed-off-by: Phil Sutter <phil@nwl.cc>
|
|
 |
ad45ff |
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
 |
ad45ff |
---
|
|
 |
ad45ff |
src/evaluate.c | 10 +++++++---
|
|
 |
ad45ff |
1 file changed, 7 insertions(+), 3 deletions(-)
|
|
 |
ad45ff |
|
|
 |
ad45ff |
diff --git a/src/evaluate.c b/src/evaluate.c
|
|
 |
ad45ff |
index 25a7376..8552e4a 100644
|
|
 |
ad45ff |
--- a/src/evaluate.c
|
|
 |
ad45ff |
+++ b/src/evaluate.c
|
|
 |
ad45ff |
@@ -2136,8 +2136,10 @@ static int stmt_reject_gen_dependency(struct eval_ctx *ctx, struct stmt *stmt,
|
|
 |
ad45ff |
if (ret <= 0)
|
|
 |
ad45ff |
return ret;
|
|
 |
ad45ff |
|
|
 |
ad45ff |
- if (payload_gen_dependency(ctx, payload, &nstmt) < 0)
|
|
 |
ad45ff |
- return -1;
|
|
 |
ad45ff |
+ if (payload_gen_dependency(ctx, payload, &nstmt) < 0) {
|
|
 |
ad45ff |
+ ret = -1;
|
|
 |
ad45ff |
+ goto out;
|
|
 |
ad45ff |
+ }
|
|
 |
ad45ff |
|
|
 |
ad45ff |
/*
|
|
 |
ad45ff |
* Unlike payload deps this adds the dependency at the beginning, i.e.
|
|
 |
ad45ff |
@@ -2148,7 +2150,9 @@ static int stmt_reject_gen_dependency(struct eval_ctx *ctx, struct stmt *stmt,
|
|
 |
ad45ff |
* Otherwise we'd log things that won't be rejected.
|
|
 |
ad45ff |
*/
|
|
 |
ad45ff |
list_add(&nstmt->list, &ctx->rule->stmts);
|
|
 |
ad45ff |
- return 0;
|
|
 |
ad45ff |
+out:
|
|
 |
ad45ff |
+ xfree(payload);
|
|
 |
ad45ff |
+ return ret;
|
|
 |
ad45ff |
}
|
|
 |
ad45ff |
|
|
 |
ad45ff |
static int stmt_evaluate_reject_inet_family(struct eval_ctx *ctx,
|
|
 |
ad45ff |
--
|
|
 |
ad45ff |
1.8.3.1
|
|
 |
ad45ff |
|