[PATCH 4/7] xtables: set custom opts to NULL on free

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When inside ip6tables-restore, xtables_free_opts can be called
multiple times, especially when trying to exit with an error message
from outside do_command. So set it to NULL so that we do not attempt
to free a dangling pointer.

Signed-off-by: Jan Engelhardt <jengelh@xxxxxxxxxx>
---
 xtables.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/xtables.c b/xtables.c
index 0036299..be103d7 100644
--- a/xtables.c
+++ b/xtables.c
@@ -75,8 +75,10 @@ void basic_exit_err(enum xtables_exittype status, const char *msg, ...)
 
 void xtables_free_opts(int unused)
 {
-	if (xt_params->opts != xt_params->orig_opts)
+	if (xt_params->opts != xt_params->orig_opts) {
 		free(xt_params->opts);
+		xt_params->opts = NULL;
+	}
 }
 
 struct option *xtables_merge_options(struct option *orig_opts,
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux