From 3dc433b55bbfaf9df3ee408aaa6282742f377864 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Fri, 20 Sep 2019 17:31:58 +0200 Subject: xtables-restore: Fix --table parameter check Xtables-restore tries to reject rule commands in input which contain a --table parameter (since it is adding this itself based on the previous table line). The manual check was not perfect though as it caught any parameter starting with a dash and containing a 't' somewhere, even in rule comments: | *filter | -A FORWARD -m comment --comment "- allow this one" -j ACCEPT | COMMIT Instead of error-prone manual checking, go a much simpler route: All do_command callbacks are passed a boolean indicating they're called from *tables-restore. React upon this when handling a table parameter and error out if it's not the first one. Fixes: f8e5ebc5986bf ("iptables: Fix crash on malformed iptables-restore") Signed-off-by: Phil Sutter Acked-by: Florian Westphal --- iptables/xshared.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'iptables/xshared.c') diff --git a/iptables/xshared.c b/iptables/xshared.c index ba723f59..5211b647 100644 --- a/iptables/xshared.c +++ b/iptables/xshared.c @@ -533,18 +533,6 @@ void add_param_to_argv(char *parsestart, int line) } param.buffer[param.len] = '\0'; - - /* check if table name specified */ - if ((param.buffer[0] == '-' && - param.buffer[1] != '-' && - strchr(param.buffer, 't')) || - (!strncmp(param.buffer, "--t", 3) && - !strncmp(param.buffer, "--table", strlen(param.buffer)))) { - xtables_error(PARAMETER_PROBLEM, - "The -t option (seen in line %u) cannot be used in %s.\n", - line, xt_params->program_name); - } - add_argv(param.buffer, 0); param.len = 0; } -- cgit v1.2.3