if (arg == NULL)
return -1;
- xtables_init_all(&tcipt_globals, NFPROTO_IPV4);
+ /* copy tcipt_globals because .opts will be modified by iptables */
+ struct xtables_globals tmp_tcipt_globals = tcipt_globals;
+
+ xtables_init_all(&tmp_tcipt_globals, NFPROTO_IPV4);
set_lib_dir();
parse_rtattr_nested(tb, TCA_IPT_MAX, arg);
}
#if (XTABLES_VERSION_CODE >= 6)
- opts = xtables_options_xfrm(tcipt_globals.orig_opts,
- tcipt_globals.opts,
+ opts = xtables_options_xfrm(tmp_tcipt_globals.orig_opts,
+ tmp_tcipt_globals.opts,
m->x6_options,
&m->option_offset);
#else
- opts = xtables_merge_options(tcipt_globals.opts,
+ opts = xtables_merge_options(tmp_tcipt_globals.opts,
m->extra_opts,
&m->option_offset);
#endif
fprintf(stderr, " failed to find aditional options for target %s\n\n", optarg);
return -1;
} else
- tcipt_globals.opts = opts;
+ tmp_tcipt_globals.opts = opts;
} else {
fprintf(stderr, " failed to find target %s\n\n",
t->u.user.name);