diff mbox series

[nft] parser_json: Fix checking of parse_policy() return code

Message ID 20191021144055.13567-1-phil@nwl.cc
State Accepted
Headers show
Series [nft] parser_json: Fix checking of parse_policy() return code | expand

Commit Message

Phil Sutter Oct. 21, 2019, 2:40 p.m. UTC
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>
---
 src/parser_json.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Pablo Neira Ayuso Oct. 21, 2019, 3:59 p.m. UTC | #1
On Mon, Oct 21, 2019 at 04:40:55PM +0200, Phil Sutter wrote:
> 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>
diff mbox series

Patch

diff --git a/src/parser_json.c b/src/parser_json.c
index 55dbc177cc98d..fe0c5df98f5d4 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -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;