From 85ca21be00b2521db5c6eb2f4dc6118fd85173ea Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Mon, 30 Sep 2024 13:59:17 +0200 Subject: rest: validate name in repository/{add,update} do not allow request without name. --- src/rest.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/rest.c b/src/rest.c index 876c0a8..f233f6b 100644 --- a/src/rest.c +++ b/src/rest.c @@ -4802,6 +4802,7 @@ static int og_cmd_post_repository_update(json_t *element, } else if (!strcmp(key, "name")) { err = og_json_parse_string_copy(value, name, sizeof(name)); + params->flags |= OG_REST_PARAM_NAME; } else if (!strcmp(key, "addr")) { err = og_json_parse_clients(value, params); } @@ -4810,6 +4811,7 @@ static int og_cmd_post_repository_update(json_t *element, return err; } if (!og_msg_params_validate(params, OG_REST_PARAM_ID | + OG_REST_PARAM_NAME | OG_REST_PARAM_ADDR)) return -1; @@ -4884,6 +4886,7 @@ static int og_cmd_post_repository_add(json_t *element, if (!strcmp(key, "name")) { err = og_json_parse_string_copy(value, name, sizeof(name)); + params->flags |= OG_REST_PARAM_NAME; } else if (!strcmp(key, "addr")) { err = og_json_parse_clients(value, params); } @@ -4892,7 +4895,8 @@ static int og_cmd_post_repository_add(json_t *element, return err; } - if (!og_msg_params_validate(params, OG_REST_PARAM_ADDR)) + if (!og_msg_params_validate(params, OG_REST_PARAM_ADDR | + OG_REST_PARAM_NAME)) return -1; dbi = og_dbi_open(&ogconfig.db); -- cgit v1.2.3-18-g5258