mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-04 14:20:09 +00:00
[SBI] Crash occurs when ENUM in the MAP (#2103)
This commit is contained in:
parent
ce668c556c
commit
969c116e77
1097 changed files with 266728 additions and 42047 deletions
|
|
@ -24,22 +24,33 @@ OpenAPI_psa_information_t *OpenAPI_psa_information_create(
|
|||
|
||||
void OpenAPI_psa_information_free(OpenAPI_psa_information_t *psa_information)
|
||||
{
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (NULL == psa_information) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
OpenAPI_list_for_each(psa_information->dnai_list, node) {
|
||||
ogs_free(node->data);
|
||||
if (psa_information->dnai_list) {
|
||||
OpenAPI_list_for_each(psa_information->dnai_list, node) {
|
||||
ogs_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(psa_information->dnai_list);
|
||||
psa_information->dnai_list = NULL;
|
||||
}
|
||||
if (psa_information->ue_ipv6_prefix) {
|
||||
ogs_free(psa_information->ue_ipv6_prefix);
|
||||
psa_information->ue_ipv6_prefix = NULL;
|
||||
}
|
||||
if (psa_information->psa_upf_id) {
|
||||
ogs_free(psa_information->psa_upf_id);
|
||||
psa_information->psa_upf_id = NULL;
|
||||
}
|
||||
OpenAPI_list_free(psa_information->dnai_list);
|
||||
ogs_free(psa_information->ue_ipv6_prefix);
|
||||
ogs_free(psa_information->psa_upf_id);
|
||||
ogs_free(psa_information);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_psa_information_convertToJSON(OpenAPI_psa_information_t *psa_information)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (psa_information == NULL) {
|
||||
ogs_error("OpenAPI_psa_information_convertToJSON() failed [PsaInformation]");
|
||||
|
|
@ -47,7 +58,7 @@ cJSON *OpenAPI_psa_information_convertToJSON(OpenAPI_psa_information_t *psa_info
|
|||
}
|
||||
|
||||
item = cJSON_CreateObject();
|
||||
if (psa_information->psa_ind) {
|
||||
if (psa_information->psa_ind != OpenAPI_psa_indication_NULL) {
|
||||
if (cJSON_AddStringToObject(item, "psaInd", OpenAPI_psa_indication_ToString(psa_information->psa_ind)) == NULL) {
|
||||
ogs_error("OpenAPI_psa_information_convertToJSON() failed [psa_ind]");
|
||||
goto end;
|
||||
|
|
@ -55,19 +66,17 @@ cJSON *OpenAPI_psa_information_convertToJSON(OpenAPI_psa_information_t *psa_info
|
|||
}
|
||||
|
||||
if (psa_information->dnai_list) {
|
||||
cJSON *dnai_list = cJSON_AddArrayToObject(item, "dnaiList");
|
||||
if (dnai_list == NULL) {
|
||||
cJSON *dnai_listList = cJSON_AddArrayToObject(item, "dnaiList");
|
||||
if (dnai_listList == NULL) {
|
||||
ogs_error("OpenAPI_psa_information_convertToJSON() failed [dnai_list]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *dnai_list_node;
|
||||
OpenAPI_list_for_each(psa_information->dnai_list, dnai_list_node) {
|
||||
if (cJSON_AddStringToObject(dnai_list, "", (char*)dnai_list_node->data) == NULL) {
|
||||
ogs_error("OpenAPI_psa_information_convertToJSON() failed [dnai_list]");
|
||||
goto end;
|
||||
OpenAPI_list_for_each(psa_information->dnai_list, node) {
|
||||
if (cJSON_AddStringToObject(dnai_listList, "", (char*)node->data) == NULL) {
|
||||
ogs_error("OpenAPI_psa_information_convertToJSON() failed [dnai_list]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (psa_information->ue_ipv6_prefix) {
|
||||
|
|
@ -91,9 +100,14 @@ end:
|
|||
OpenAPI_psa_information_t *OpenAPI_psa_information_parseFromJSON(cJSON *psa_informationJSON)
|
||||
{
|
||||
OpenAPI_psa_information_t *psa_information_local_var = NULL;
|
||||
cJSON *psa_ind = cJSON_GetObjectItemCaseSensitive(psa_informationJSON, "psaInd");
|
||||
|
||||
OpenAPI_psa_indication_e psa_indVariable;
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
cJSON *psa_ind = NULL;
|
||||
OpenAPI_psa_indication_e psa_indVariable = 0;
|
||||
cJSON *dnai_list = NULL;
|
||||
OpenAPI_list_t *dnai_listList = NULL;
|
||||
cJSON *ue_ipv6_prefix = NULL;
|
||||
cJSON *psa_upf_id = NULL;
|
||||
psa_ind = cJSON_GetObjectItemCaseSensitive(psa_informationJSON, "psaInd");
|
||||
if (psa_ind) {
|
||||
if (!cJSON_IsString(psa_ind)) {
|
||||
ogs_error("OpenAPI_psa_information_parseFromJSON() failed [psa_ind]");
|
||||
|
|
@ -102,39 +116,38 @@ OpenAPI_psa_information_t *OpenAPI_psa_information_parseFromJSON(cJSON *psa_info
|
|||
psa_indVariable = OpenAPI_psa_indication_FromString(psa_ind->valuestring);
|
||||
}
|
||||
|
||||
cJSON *dnai_list = cJSON_GetObjectItemCaseSensitive(psa_informationJSON, "dnaiList");
|
||||
|
||||
OpenAPI_list_t *dnai_listList;
|
||||
dnai_list = cJSON_GetObjectItemCaseSensitive(psa_informationJSON, "dnaiList");
|
||||
if (dnai_list) {
|
||||
cJSON *dnai_list_local;
|
||||
if (!cJSON_IsArray(dnai_list)) {
|
||||
ogs_error("OpenAPI_psa_information_parseFromJSON() failed [dnai_list]");
|
||||
goto end;
|
||||
}
|
||||
dnai_listList = OpenAPI_list_create();
|
||||
cJSON *dnai_list_local = NULL;
|
||||
if (!cJSON_IsArray(dnai_list)) {
|
||||
ogs_error("OpenAPI_psa_information_parseFromJSON() failed [dnai_list]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
cJSON_ArrayForEach(dnai_list_local, dnai_list) {
|
||||
if (!cJSON_IsString(dnai_list_local)) {
|
||||
ogs_error("OpenAPI_psa_information_parseFromJSON() failed [dnai_list]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(dnai_listList, ogs_strdup(dnai_list_local->valuestring));
|
||||
}
|
||||
dnai_listList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(dnai_list_local, dnai_list) {
|
||||
double *localDouble = NULL;
|
||||
int *localInt = NULL;
|
||||
if (!cJSON_IsString(dnai_list_local)) {
|
||||
ogs_error("OpenAPI_psa_information_parseFromJSON() failed [dnai_list]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(dnai_listList, ogs_strdup(dnai_list_local->valuestring));
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *ue_ipv6_prefix = cJSON_GetObjectItemCaseSensitive(psa_informationJSON, "ueIpv6Prefix");
|
||||
|
||||
ue_ipv6_prefix = cJSON_GetObjectItemCaseSensitive(psa_informationJSON, "ueIpv6Prefix");
|
||||
if (ue_ipv6_prefix) {
|
||||
if (!cJSON_IsString(ue_ipv6_prefix)) {
|
||||
if (!cJSON_IsString(ue_ipv6_prefix) && !cJSON_IsNull(ue_ipv6_prefix)) {
|
||||
ogs_error("OpenAPI_psa_information_parseFromJSON() failed [ue_ipv6_prefix]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *psa_upf_id = cJSON_GetObjectItemCaseSensitive(psa_informationJSON, "psaUpfId");
|
||||
|
||||
psa_upf_id = cJSON_GetObjectItemCaseSensitive(psa_informationJSON, "psaUpfId");
|
||||
if (psa_upf_id) {
|
||||
if (!cJSON_IsString(psa_upf_id)) {
|
||||
if (!cJSON_IsString(psa_upf_id) && !cJSON_IsNull(psa_upf_id)) {
|
||||
ogs_error("OpenAPI_psa_information_parseFromJSON() failed [psa_upf_id]");
|
||||
goto end;
|
||||
}
|
||||
|
|
@ -143,12 +156,19 @@ OpenAPI_psa_information_t *OpenAPI_psa_information_parseFromJSON(cJSON *psa_info
|
|||
psa_information_local_var = OpenAPI_psa_information_create (
|
||||
psa_ind ? psa_indVariable : 0,
|
||||
dnai_list ? dnai_listList : NULL,
|
||||
ue_ipv6_prefix ? ogs_strdup(ue_ipv6_prefix->valuestring) : NULL,
|
||||
psa_upf_id ? ogs_strdup(psa_upf_id->valuestring) : NULL
|
||||
ue_ipv6_prefix && !cJSON_IsNull(ue_ipv6_prefix) ? ogs_strdup(ue_ipv6_prefix->valuestring) : NULL,
|
||||
psa_upf_id && !cJSON_IsNull(psa_upf_id) ? ogs_strdup(psa_upf_id->valuestring) : NULL
|
||||
);
|
||||
|
||||
return psa_information_local_var;
|
||||
end:
|
||||
if (dnai_listList) {
|
||||
OpenAPI_list_for_each(dnai_listList, node) {
|
||||
ogs_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(dnai_listList);
|
||||
dnai_listList = NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue