diff options
author | Roberto Hueso Gómez <rhueso@soleta.eu> | 2019-11-05 11:40:30 +0100 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2019-11-06 11:26:45 +0100 |
commit | c80150e1aba284685c0f1400bc51e14c15549a45 (patch) | |
tree | 854439919b3518b27820d260d724676833746647 /admin/Sources/Services | |
parent | a0df5af7248f31bab8a799268e35373936d5911c (diff) |
#915 Validate POST /software REST API parameters
This patch ensures that all required parameters are sent in the request.
Diffstat (limited to 'admin/Sources/Services')
-rw-r--r-- | admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp b/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp index db95298c..553cccca 100644 --- a/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp +++ b/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp @@ -3975,15 +3975,24 @@ static int og_cmd_software(json_t *element, struct og_msg_params *params) json_object_foreach(element, key, value) { if (!strcmp(key, "clients")) err = og_json_parse_clients(value, params); - else if (!strcmp(key, "disk")) + else if (!strcmp(key, "disk")) { err = og_json_parse_string(value, ¶ms->disk); - else if (!strcmp(key, "partition")) + params->flags |= OG_REST_PARAM_DISK; + } + else if (!strcmp(key, "partition")) { err = og_json_parse_string(value, ¶ms->partition); + params->flags |= OG_REST_PARAM_PARTITION; + } if (err < 0) break; } + if (!og_msg_params_validate(params, OG_REST_PARAM_ADDR | + OG_REST_PARAM_DISK | + OG_REST_PARAM_PARTITION)) + return -1; + len = snprintf(buf, sizeof(buf), "nfn=InventarioSoftware\rdsk=%s\rpar=%s\r", params->disk, params->partition); |