]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
parser_json: Fix checking of parse_policy() return code
authorPhil Sutter <phil@nwl.cc>
Mon, 21 Oct 2019 14:20:10 +0000 (16:20 +0200)
committerPhil Sutter <phil@nwl.cc>
Mon, 21 Oct 2019 16:21:08 +0000 (18:21 +0200)
The function was changed to return an expression or NULL but error
checking wasn't adjusted while doing so.

Fixes: dba4a9b4b5fe2 ("src: allow variable in chain policy")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/parser_json.c

index 55dbc177cc98ddf6cac6a18f653dc396115e4b23..fe0c5df98f5d40a72a7d3dfc1710714549c45f01 100644 (file)
@@ -2630,7 +2630,7 @@ static struct cmd *json_parse_cmd_add_chain(struct json_ctx *ctx, json_t *root,
                chain->dev = xstrdup(chain->dev);
        if (!json_unpack(root, "{s:s}", "policy", &policy)) {
                chain->policy = parse_policy(policy);
-               if (chain->policy < 0) {
+               if (!chain->policy) {
                        json_error(ctx, "Unknown policy '%s'.", policy);
                        chain_free(chain);
                        return NULL;