]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
state: report spaces in the state list parsing
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 19 Nov 2008 18:01:26 +0000 (19:01 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 19 Nov 2008 18:01:26 +0000 (19:01 +0100)
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>
extensions/libxt_conntrack.c
extensions/libxt_state.c

index 3cec9dd47d03dd11147304da4be9f9597ca28ad4..c7f80e0d685fa14dd6d984f19f08aee6b6b4e397 100644 (file)
@@ -107,7 +107,10 @@ parse_states(const char *arg, struct xt_conntrack_info *sinfo)
                        exit_error(PARAMETER_PROBLEM, "Bad ctstate `%s'", arg);
                arg = comma+1;
        }
-
+       if (!*arg)
+               exit_error(PARAMETER_PROBLEM, "`--ctstate' requires a list of "
+                                             "states with no spaces, e.g. "
+                                             "ESTABLISHED,RELATED");
        if (strlen(arg) == 0 || !parse_state(arg, strlen(arg), sinfo))
                exit_error(PARAMETER_PROBLEM, "Bad ctstate `%s'", arg);
 }
index 95d7db5733abaa1cbf195e29587e8cb6f0721e42..66af518a2a8fe77a183b0b2e111d2bdfb7dcebc2 100644 (file)
@@ -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);
 }