mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Fix inform parameter name accepts forced inform parameter
This commit is contained in:
parent
f178257263
commit
d36c03529b
4 changed files with 50 additions and 9 deletions
19
src/common.c
19
src/common.c
|
|
@ -15,6 +15,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <regex.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "cwmp_cli.h"
|
#include "cwmp_cli.h"
|
||||||
|
|
@ -782,3 +783,21 @@ bool uci_str_to_bool(char *value)
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool match_reg_exp(char *reg_exp, char *param_name)
|
||||||
|
{
|
||||||
|
if (reg_exp == NULL || param_name == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
regex_t reegex;
|
||||||
|
int ret = regcomp(&reegex, reg_exp, REG_EXTENDED);
|
||||||
|
if (ret != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ret = regexec(&reegex, param_name, 0, NULL, 0);
|
||||||
|
regfree(&reegex);
|
||||||
|
if (ret != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -546,5 +546,6 @@ int cwmp_schedule_rpc(struct cwmp *cwmp, struct session *session);
|
||||||
int run_session_end_func(void);
|
int run_session_end_func(void);
|
||||||
void set_interface_reset_request(char *param_name, char *value);
|
void set_interface_reset_request(char *param_name, char *value);
|
||||||
bool uci_str_to_bool(char *value);
|
bool uci_str_to_bool(char *value);
|
||||||
|
bool match_reg_exp(char *reg_exp, char *param_name);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
10
src/cwmp.c
10
src/cwmp.c
|
|
@ -17,7 +17,6 @@
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <regex.h>
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "ssl_utils.h"
|
#include "ssl_utils.h"
|
||||||
|
|
@ -82,14 +81,7 @@ static bool interface_reset_req(char *param_name, char *value)
|
||||||
char reg_exp[60] = {0};
|
char reg_exp[60] = {0};
|
||||||
snprintf(reg_exp, sizeof(reg_exp), "^(%s|%s)[0-9]+.Reset$", DM_IP_INTERFACE_PATH, DM_PPP_INTERFACE_PATH);
|
snprintf(reg_exp, sizeof(reg_exp), "^(%s|%s)[0-9]+.Reset$", DM_IP_INTERFACE_PATH, DM_PPP_INTERFACE_PATH);
|
||||||
|
|
||||||
regex_t reegex;
|
if (match_reg_exp(reg_exp, param_name) == false)
|
||||||
int ret = regcomp(&reegex, reg_exp, REG_EXTENDED);
|
|
||||||
if (ret != 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ret = regexec(&reegex, param_name, 0, NULL, 0);
|
|
||||||
regfree(&reegex);
|
|
||||||
if (ret != 0)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (strcmp(value, "1") != 0 && strcmp(value, "true") != 0)
|
if (strcmp(value, "1") != 0 && strcmp(value, "true") != 0)
|
||||||
|
|
|
||||||
29
src/rpc.c
29
src/rpc.c
|
|
@ -363,6 +363,30 @@ static void load_inform_xml_schema(mxml_node_t **tree, struct cwmp *cwmp, struct
|
||||||
*tree = xml;
|
*tree = xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int validate_inform_parameter_name(struct list_head *parameters_values_list)
|
||||||
|
{
|
||||||
|
struct cwmp_dm_parameter *param_value = NULL;
|
||||||
|
char reg_exp[65] = {0};
|
||||||
|
snprintf(reg_exp, sizeof(reg_exp), "^Device.ManagementServer.InformParameter.[0-9]+.ParameterName$");
|
||||||
|
|
||||||
|
list_for_each_entry(param_value, parameters_values_list, list) {
|
||||||
|
if (param_value->name == NULL || param_value->value == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (match_reg_exp(reg_exp, param_value->name) == false)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
size_t inform_parameters_nbr = sizeof(forced_inform_parameters) / sizeof(forced_inform_parameters[0]);
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < inform_parameters_nbr; i++) {
|
||||||
|
if (strcmp(forced_inform_parameters[i], param_value->value) == 0)
|
||||||
|
return FAULT_CPE_INVALID_PARAMETER_VALUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FAULT_CPE_NO_FAULT;
|
||||||
|
}
|
||||||
|
|
||||||
int cwmp_rpc_acs_prepare_message_inform(struct cwmp *cwmp, struct session *session, struct rpc *this __attribute__((unused)))
|
int cwmp_rpc_acs_prepare_message_inform(struct cwmp *cwmp, struct session *session, struct rpc *this __attribute__((unused)))
|
||||||
{
|
{
|
||||||
mxml_node_t *tree;
|
mxml_node_t *tree;
|
||||||
|
|
@ -909,6 +933,11 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct session *session, struct rpc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Before set check if exists Device.ManagementServer.InformParameter.{i}.ParameterName with ForcedInform Parameter */
|
||||||
|
fault_code = validate_inform_parameter_name(&list_set_param_value);
|
||||||
|
if (fault_code != FAULT_CPE_NO_FAULT)
|
||||||
|
goto fault;
|
||||||
|
|
||||||
fault_code = cwmp_set_multiple_parameters_values(&list_set_param_value, parameter_key ? parameter_key : "", &flag, rpc->list_set_value_fault);
|
fault_code = cwmp_set_multiple_parameters_values(&list_set_param_value, parameter_key ? parameter_key : "", &flag, rpc->list_set_value_fault);
|
||||||
if (fault_code != FAULT_CPE_NO_FAULT)
|
if (fault_code != FAULT_CPE_NO_FAULT)
|
||||||
goto fault;
|
goto fault;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue