]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
ebtables-nft: don't crash on ebtables -X
authorFlorian Westphal <fw@strlen.de>
Thu, 28 Jun 2018 22:15:25 +0000 (00:15 +0200)
committerFlorian Westphal <fw@strlen.de>
Fri, 29 Jun 2018 12:37:01 +0000 (14:37 +0200)
Signed-off-by: Florian Westphal <fw@strlen.de>
iptables/xtables-eb.c

index e22181eebe603d52b4ed7a7bb5f24034e61544f1..9460a91a36ee64c5ebaedd0b25a4aaea666e6f66 100644 (file)
@@ -208,6 +208,9 @@ delete_entry(struct nft_handle *h,
 
 static int get_current_chain(const char *chain)
 {
+       if (!chain)
+               return -1;
+
        if (strcmp(chain, "PREROUTING") == 0)
                return NF_BR_PRE_ROUTING;
        else if (strcmp(chain, "INPUT") == 0)
@@ -823,13 +826,12 @@ int do_commandeb(struct nft_handle *h, int argc, char *argv[], char **table)
                                              "Multiple commands are not allowed");
 
                        command = c;
+                       if (optarg && (optarg[0] == '-' || !strcmp(optarg, "!")))
+                               xtables_error(PARAMETER_PROBLEM, "No chain name specified");
                        chain = optarg;
                        selected_chain = get_current_chain(chain);
                        flags |= OPT_COMMAND;
-                       /*if (!(replace->flags & OPT_KERNELDATA))
-                               ebt_get_kernel_table(replace, 0);*/
-                       /*if (optarg && (optarg[0] == '-' || !strcmp(optarg, "!")))
-                               ebt_print_error2("No chain name specified");*/
+
                        if (c == 'N') {
                                ret = nft_chain_user_add(h, chain, *table);
                                break;