diff options
author | OpenGnSys Support Team <soporte-og@soleta.eu> | 2024-09-30 13:59:17 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2024-09-30 14:41:49 +0200 |
commit | 85ca21be00b2521db5c6eb2f4dc6118fd85173ea (patch) | |
tree | b02bc4885eacc216c2a1472f57a614d477042c90 /src | |
parent | 760a82af2ced2365a8626af146ff2668b806c62f (diff) |
rest: validate name in repository/{add,update}
do not allow request without name.
Diffstat (limited to 'src')
-rw-r--r-- | src/rest.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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); |