OCT 修改参数异常判断

This commit is contained in:
dongwenze 2022-12-09 18:04:18 +08:00
parent 9efa161728
commit 3ef2b0672c
1 changed files with 17 additions and 14 deletions

View File

@ -448,6 +448,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
cJSON_AddItemToObject(pRspRoot, "rangeSet", pdelArray);
for (int i = 0; i < cJSON_GetArraySize(pdhcp_range); i++) {
cJSON *pdel_Item = cJSON_CreateObject();
cJSON *pdelRange = cJSON_GetArrayItem(pdhcp_range, i);
char del_range[256];
auto *delItem = (struct hash_map *)malloc(sizeof(hash_map));
@ -465,6 +466,13 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
mySplit(start, end, del_range, '-');
st_addr = htonl(inet_addr(start));
en_addr = htonl(inet_addr(end));
if(en_addr == 0) {
cJSON_AddStringToObject(pdel_Item, "dhcpRange", del_range);
cJSON_AddNumberToObject(pdel_Item, "status", ERR_INPUT_PARAMS);
cJSON_AddStringToObject(pdel_Item, "message", getErrorEnumDesc(ERR_INPUT_PARAMS));
cJSON_AddItemToArray(pdelArray, pdel_Item);
}
HASH_FIND_INT(delMap, &st_addr, delItem);
if (delItem == nullptr) {
@ -491,7 +499,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
sprintf(del_range, "%s-%s", saddr, eaddr);
cJSON_AddStringToObject(pdel_Item, "dhcpRange", del_range);
//judge whether the input has error
if(delRange->key && delRange->value && (delRange->value == cfig.dhcpRanges[i].rangeEnd)){
if(delRange->value == cfig.dhcpRanges[i].rangeEnd) {
cJSON_AddNumberToObject(pdel_Item, "status", ERR_SUCCESS);
cJSON_AddStringToObject(pdel_Item, "message", getErrorEnumDesc(ERR_SUCCESS));
cJSON_AddItemToArray(pdelArray, pdel_Item);
@ -504,10 +512,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
cJSON_AddItemToArray(pdelArray, pdel_Item);
}
hash_map *s = (struct hash_map*)malloc(sizeof(struct hash_map));
s->key = delRange->key;
s->value = 0;
HASH_REPLACE_INT(delMap, key, s, delRange);
HASH_DEL(delMap, delRange);
} else {
//write to dhcpRanges
memcpy(&dhcpRanges[resCount], &cfig.dhcpRanges[i], sizeof(struct data13));
@ -526,7 +531,6 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
memset(del_range, 0, 256);
HASH_ITER(hh, delMap, s, tmp){
if(s->value != 0){
IP2String(saddr, ntohl(s->key));
IP2String(eaddr, ntohl(s->value));
@ -538,7 +542,6 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
cJSON_AddItemToArray(pdelArray, pdel_Item);
}
}
}
//rewite cfig.dhcpRanges
for (int i = 0; i < cfig.rangeCount; i++) {