iptables: Reset pointer after freeing
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Thu, 21 Feb 2013 16:42:30 +0000 (17:42 +0100)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 22 Feb 2013 10:42:52 +0000 (12:42 +0200)
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.

src/iptables.c

index 4d46a5b..44c5c73 100644 (file)
@@ -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);
 }