diff options
author | Fernando Fernandez Mancera <ffmancera@riseup.net> | 2022-09-02 15:35:06 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2022-09-03 16:04:26 +0200 |
commit | 482fc1f21a40b7f2e11ddfc73e0b82027e68d345 (patch) | |
tree | 5cfb9c0540f3d19be7c46c83004d57f23492e06a /src | |
parent | e66f3187d891a7b2f7212f33ab7501d5ee6c3b2f (diff) |
json: fix json schema version verification
nft should ignore malformed or missing entries of `json_schema_version` but
check the value when it is integer.
Link: https://bugzilla.netfilter.org/show_bug.cgi?id=1490
Fixes: 49e0f1dc6e52 ("JSON: Add metainfo object to all output")
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/parser_json.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/parser_json.c b/src/parser_json.c index 7180474e..46dca9fd 100644 --- a/src/parser_json.c +++ b/src/parser_json.c @@ -3862,13 +3862,14 @@ static int json_verify_metainfo(struct json_ctx *ctx, json_t *root) { int schema_version; - if (!json_unpack(root, "{s:i}", "json_schema_version", &schema_version)) - return 0; - - if (schema_version > JSON_SCHEMA_VERSION) { - json_error(ctx, "Schema version %d not supported, maximum supported version is %d\n", - schema_version, JSON_SCHEMA_VERSION); - return 1; + if (!json_unpack(root, "{s:i}", "json_schema_version", &schema_version)) { + if (schema_version > JSON_SCHEMA_VERSION) { + json_error(ctx, + "Schema version %d not supported, maximum" + " supported version is %d\n", + schema_version, JSON_SCHEMA_VERSION); + return 1; + } } return 0; |