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 | b403c7ae6cf1e2c423e8d26969d4dca201ebd93f (patch) | |
tree | 4453c9b6cad9ce667e3d0ca2187e4483058eb8a5 | |
parent | ec5fe704ccfe92a3dcbaf8ef15f214caa6de0357 (diff) |
#915 Validate POST /shell/run REST API parameters
This patch ensures that all required parameters are sent in the request.
-rw-r--r-- | sources/ogAdmServer.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sources/ogAdmServer.cpp b/sources/ogAdmServer.cpp index 4d61a8a..fb84355 100644 --- a/sources/ogAdmServer.cpp +++ b/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]); |