summaryrefslogtreecommitdiffstats
path: root/iptables/xshared.c
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@medozas.de>2011-06-07 22:20:13 +0200
committerJan Engelhardt <jengelh@medozas.de>2011-06-07 22:33:13 +0200
commit780607f8b040a47cd2d4775376e2d30f567dc049 (patch)
tree1dc9372b7556774c0164241929b4c4edfbf163f1 /iptables/xshared.c
parent6a74dc80fcdf48e2b149e92aee08f3445055ea3b (diff)
option: fix ignored negation before implicit extension loading
`iptables -A INPUT -p tcp ! --syn` forgot the negation, i.e. it was not present in a subsequent `iptables -S`. Commit v1.4.11~77^2~9 missed the fact that after autoloading a proto extension, cs.invert must not be touched until the next getopt call. This is now fixed by having command_default return a value to indicate whether to jump or not. Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Diffstat (limited to 'iptables/xshared.c')
-rw-r--r--iptables/xshared.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/iptables/xshared.c b/iptables/xshared.c
index 4651888a..0e3857bb 100644
--- a/iptables/xshared.c
+++ b/iptables/xshared.c
@@ -104,8 +104,8 @@ struct xtables_match *load_proto(struct iptables_command_state *cs)
cs->options & OPT_NUMERIC, &cs->matches);
}
-void command_default(struct iptables_command_state *cs,
- struct xtables_globals *gl)
+int command_default(struct iptables_command_state *cs,
+ struct xtables_globals *gl)
{
struct xtables_rule_match *matchp;
struct xtables_match *m;
@@ -116,7 +116,7 @@ void command_default(struct iptables_command_state *cs,
cs->c < cs->target->option_offset + XT_OPTION_OFFSET_SCALE) {
xtables_option_tpcall(cs->c, cs->argv, cs->invert,
cs->target, &cs->fw);
- return;
+ return 0;
}
for (matchp = cs->matches; matchp; matchp = matchp->next) {
@@ -129,7 +129,7 @@ void command_default(struct iptables_command_state *cs,
cs->c >= matchp->match->option_offset + XT_OPTION_OFFSET_SCALE)
continue;
xtables_option_mpcall(cs->c, cs->argv, cs->invert, m, &cs->fw);
- return;
+ return 0;
}
/* Try loading protocol */
@@ -161,7 +161,8 @@ void command_default(struct iptables_command_state *cs,
if (gl->opts == NULL)
xtables_error(OTHER_PROBLEM, "can't alloc memory!");
optind--;
- return;
+ /* Indicate to rerun getopt *immediately* */
+ return 1;
}
if (cs->c == ':')
@@ -171,6 +172,7 @@ void command_default(struct iptables_command_state *cs,
xtables_error(PARAMETER_PROBLEM, "unknown option "
"\"%s\"", cs->argv[optind-1]);
xtables_error(PARAMETER_PROBLEM, "Unknown arg \"%s\"", optarg);
+ return 0;
}
static mainfunc_t subcmd_get(const char *cmd, const struct subcommand *cb)