summaryrefslogtreecommitdiff
path: root/src/iptables.c
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2013-02-21 17:42:30 +0100
committerPatrik Flykt <patrik.flykt@linux.intel.com>2013-02-22 12:42:52 +0200
commit4f30adc930c73036c6d1a146cdb21933af38e0d4 (patch)
tree3128f2b2aa03e7841d15c91ed6d32dd2831ca8da /src/iptables.c
parentbdd1663c5cf56853ca745635f7448e09613d5e36 (diff)
downloadconnman-4f30adc930c73036c6d1a146cdb21933af38e0d4.tar.gz
connman-4f30adc930c73036c6d1a146cdb21933af38e0d4.tar.bz2
connman-4f30adc930c73036c6d1a146cdb21933af38e0d4.zip
iptables: Reset pointer after freeing
The match or the target might be reused in the next invocation of iptables and then xtables operates on this invalid pointer. xt_t->t and xt_m->m are keept alive via the global variables xtables_targets and xtables_matches.
Diffstat (limited to 'src/iptables.c')
-rw-r--r--src/iptables.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/iptables.c b/src/iptables.c
index 4d46a5b9..44c5c73c 100644
--- a/src/iptables.c
+++ b/src/iptables.c
@@ -2048,10 +2048,14 @@ static void cleanup_parse_context(struct parse_context *ctx)
{
g_strfreev(ctx->argv);
g_free(ctx->ip);
- if (ctx->xt_t != NULL)
+ if (ctx->xt_t != NULL) {
g_free(ctx->xt_t->t);
- if (ctx->xt_m != NULL)
+ ctx->xt_t->t = NULL;
+ }
+ if (ctx->xt_m != NULL) {
g_free(ctx->xt_m->m);
+ ctx->xt_m->m = NULL;
+ }
g_free(ctx);
}