diff options
author | Roberto Hueso Gómez <rhueso@soleta.eu> | 2019-11-05 10:41:34 +0100 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2019-11-06 11:17:19 +0100 |
commit | 3debec6024f106d54a880a1aafbb891383bb4f09 (patch) | |
tree | 4a99ff549ea77bd10d3766eb361907a8e757431d /admin | |
parent | becce94eddbf4a20d45a501a0886f1890e303c10 (diff) |
#915 Validate POST /shell/run REST API parameters
This patch ensures that all required parameters are sent in the request.
Diffstat (limited to 'admin')
-rw-r--r-- | admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp b/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp index 4d61a8ab..fb843557 100644 --- a/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp +++ b/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp @@ -3295,6 +3295,7 @@ struct og_msg_params { #define OG_REST_PARAM_ADDR (1UL << 0) #define OG_REST_PARAM_MAC (1UL << 1) #define OG_REST_PARAM_WOL_TYPE (1UL << 2) +#define OG_REST_PARAM_RUN_CMD (1UL << 3) static bool og_msg_params_validate(const struct og_msg_params *params, const uint64_t flags) @@ -3643,6 +3644,8 @@ static int og_json_parse_run(json_t *element, struct og_msg_params *params) snprintf(params->run_cmd, sizeof(params->run_cmd), "%s", json_string_value(element)); + params->flags |= OG_REST_PARAM_RUN_CMD; + return 0; } @@ -3668,6 +3671,10 @@ static int og_cmd_run_post(json_t *element, struct og_msg_params *params) break; } + if (!og_msg_params_validate(params, OG_REST_PARAM_ADDR | + OG_REST_PARAM_RUN_CMD)) + return -1; + for (i = 0; i < params->ips_array_len; i++) { len = snprintf(iph + strlen(iph), sizeof(iph), "%s;", params->ips_array[i]); |