summaryrefslogtreecommitdiffstats
path: root/extensions/libxt_state.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2008-11-19 19:01:26 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2008-11-19 19:01:26 +0100
commit0ec8c0f00b591681076af2db34df0f230b08fa2c (patch)
treee4b5394042b4c2e47c66f1b2c70a37bf9650f141 /extensions/libxt_state.c
parent0e6b7d3171988cf745d4d99006459bcea99e6e34 (diff)
state: report spaces in the state list parsing
This patch adds better error reporting when the user inserts a space between two states with the --state option. iptables -I INPUT -m state ESTABLISHED, RELATED ^ mind the space results in: iptables v1.4.2-rc1: Bad state `' Try `iptables -h' or 'iptables --help' for more information. Now this returns: iptables v1.4.2-rc1: `--state' requires a list of states with no spaces, e.g. ESTABLISHED,RELATED This patch also applies to libxt_conntrack which has a copy of the function. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'extensions/libxt_state.c')
-rw-r--r--extensions/libxt_state.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/extensions/libxt_state.c b/extensions/libxt_state.c
index 95d7db57..66af518a 100644
--- a/extensions/libxt_state.c
+++ b/extensions/libxt_state.c
@@ -54,7 +54,10 @@ state_parse_states(const char *arg, struct xt_state_info *sinfo)
exit_error(PARAMETER_PROBLEM, "Bad state `%s'", arg);
arg = comma+1;
}
-
+ if (!*arg)
+ exit_error(PARAMETER_PROBLEM, "`--state' requires a list of "
+ "states with no spaces, e.g. "
+ "ESTABLISHED,RELATED");
if (strlen(arg) == 0 || !state_parse_state(arg, strlen(arg), sinfo))
exit_error(PARAMETER_PROBLEM, "Bad state `%s'", arg);
}