]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
nft: Make rule parsing errors fatal
authorPhil Sutter <phil@nwl.cc>
Thu, 15 Dec 2022 15:17:35 +0000 (16:17 +0100)
committerPhil Sutter <phil@nwl.cc>
Tue, 20 Dec 2022 20:49:38 +0000 (21:49 +0100)
Finish parsing the rule, thereby printing all potential problems and
abort the program.

Signed-off-by: Phil Sutter <phil@nwl.cc>
iptables/nft-shared.c

index c13fc307e7a89b324ebc89f3c37a997258a460a0..4a7b5406892c4a1799ef629db109cb5b7674342d 100644 (file)
@@ -1362,7 +1362,7 @@ bool nft_rule_to_iptables_command_state(struct nft_handle *h,
                        nft_parse_range(&ctx, expr);
 
                if (ctx.errmsg) {
-                       fprintf(stderr, "%s", ctx.errmsg);
+                       fprintf(stderr, "Error: %s\n", ctx.errmsg);
                        ctx.errmsg = NULL;
                        ret = false;
                }
@@ -1404,6 +1404,8 @@ bool nft_rule_to_iptables_command_state(struct nft_handle *h,
        if (!cs->jumpto)
                cs->jumpto = "";
 
+       if (!ret)
+               xtables_error(VERSION_PROBLEM, "Parsing nftables rule failed");
        return ret;
 }