summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Garver <eric@garver.life>2019-05-01 12:34:45 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2019-05-03 18:14:38 +0200
commit92591aa0da84821238107f2f1515a57cbbd2cf6a (patch)
tree7171af06c9e41da7342153e0c4dea3557f9d4fc5
parent2d908943fa5515f27ef5dde249d0b08b92aa7ff0 (diff)
parser_json: fix crash on add rule to bad references
Pass the location via the handle so the error leg in rule_translate_index() can reference it. Applies to invalid references to tables, chains, and indexes. Fixes: 586ad210368b ("libnftables: Implement JSON parser") Signed-off-by: Eric Garver <eric@garver.life> Acked-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--src/parser_json.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/parser_json.c b/src/parser_json.c
index c57c4b8a..3dc3a5c5 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -2429,7 +2429,11 @@ static struct cmd *json_parse_cmd_add_chain(struct json_ctx *ctx, json_t *root,
static struct cmd *json_parse_cmd_add_rule(struct json_ctx *ctx, json_t *root,
enum cmd_ops op, enum cmd_obj obj)
{
- struct handle h = { 0 };
+ struct handle h = {
+ .table.location = *int_loc,
+ .chain.location = *int_loc,
+ .index.location = *int_loc,
+ };
const char *family = "", *comment = NULL;
struct rule *rule;
size_t index;