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_ec_restriction_t *OpenAPI_ec_restriction_create(
|
|||
|
||||
void OpenAPI_ec_restriction_free(OpenAPI_ec_restriction_t *ec_restriction)
|
||||
{
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (NULL == ec_restriction) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
ogs_free(ec_restriction->af_instance_id);
|
||||
OpenAPI_list_for_each(ec_restriction->plmn_ec_infos, node) {
|
||||
OpenAPI_plmn_ec_info_free(node->data);
|
||||
if (ec_restriction->af_instance_id) {
|
||||
ogs_free(ec_restriction->af_instance_id);
|
||||
ec_restriction->af_instance_id = NULL;
|
||||
}
|
||||
if (ec_restriction->plmn_ec_infos) {
|
||||
OpenAPI_list_for_each(ec_restriction->plmn_ec_infos, node) {
|
||||
OpenAPI_plmn_ec_info_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(ec_restriction->plmn_ec_infos);
|
||||
ec_restriction->plmn_ec_infos = NULL;
|
||||
}
|
||||
if (ec_restriction->mtc_provider_information) {
|
||||
ogs_free(ec_restriction->mtc_provider_information);
|
||||
ec_restriction->mtc_provider_information = NULL;
|
||||
}
|
||||
OpenAPI_list_free(ec_restriction->plmn_ec_infos);
|
||||
ogs_free(ec_restriction->mtc_provider_information);
|
||||
ogs_free(ec_restriction);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_ec_restriction_convertToJSON(OpenAPI_ec_restriction_t *ec_restriction)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (ec_restriction == NULL) {
|
||||
ogs_error("OpenAPI_ec_restriction_convertToJSON() failed [EcRestriction]");
|
||||
|
|
@ -47,6 +58,10 @@ cJSON *OpenAPI_ec_restriction_convertToJSON(OpenAPI_ec_restriction_t *ec_restric
|
|||
}
|
||||
|
||||
item = cJSON_CreateObject();
|
||||
if (!ec_restriction->af_instance_id) {
|
||||
ogs_error("OpenAPI_ec_restriction_convertToJSON() failed [af_instance_id]");
|
||||
return NULL;
|
||||
}
|
||||
if (cJSON_AddStringToObject(item, "afInstanceId", ec_restriction->af_instance_id) == NULL) {
|
||||
ogs_error("OpenAPI_ec_restriction_convertToJSON() failed [af_instance_id]");
|
||||
goto end;
|
||||
|
|
@ -63,17 +78,13 @@ cJSON *OpenAPI_ec_restriction_convertToJSON(OpenAPI_ec_restriction_t *ec_restric
|
|||
ogs_error("OpenAPI_ec_restriction_convertToJSON() failed [plmn_ec_infos]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *plmn_ec_infos_node;
|
||||
if (ec_restriction->plmn_ec_infos) {
|
||||
OpenAPI_list_for_each(ec_restriction->plmn_ec_infos, plmn_ec_infos_node) {
|
||||
cJSON *itemLocal = OpenAPI_plmn_ec_info_convertToJSON(plmn_ec_infos_node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_ec_restriction_convertToJSON() failed [plmn_ec_infos]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray(plmn_ec_infosList, itemLocal);
|
||||
OpenAPI_list_for_each(ec_restriction->plmn_ec_infos, node) {
|
||||
cJSON *itemLocal = OpenAPI_plmn_ec_info_convertToJSON(node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_ec_restriction_convertToJSON() failed [plmn_ec_infos]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray(plmn_ec_infosList, itemLocal);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -91,61 +102,60 @@ end:
|
|||
OpenAPI_ec_restriction_t *OpenAPI_ec_restriction_parseFromJSON(cJSON *ec_restrictionJSON)
|
||||
{
|
||||
OpenAPI_ec_restriction_t *ec_restriction_local_var = NULL;
|
||||
cJSON *af_instance_id = cJSON_GetObjectItemCaseSensitive(ec_restrictionJSON, "afInstanceId");
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
cJSON *af_instance_id = NULL;
|
||||
cJSON *reference_id = NULL;
|
||||
cJSON *plmn_ec_infos = NULL;
|
||||
OpenAPI_list_t *plmn_ec_infosList = NULL;
|
||||
cJSON *mtc_provider_information = NULL;
|
||||
af_instance_id = cJSON_GetObjectItemCaseSensitive(ec_restrictionJSON, "afInstanceId");
|
||||
if (!af_instance_id) {
|
||||
ogs_error("OpenAPI_ec_restriction_parseFromJSON() failed [af_instance_id]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!cJSON_IsString(af_instance_id)) {
|
||||
ogs_error("OpenAPI_ec_restriction_parseFromJSON() failed [af_instance_id]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
cJSON *reference_id = cJSON_GetObjectItemCaseSensitive(ec_restrictionJSON, "referenceId");
|
||||
reference_id = cJSON_GetObjectItemCaseSensitive(ec_restrictionJSON, "referenceId");
|
||||
if (!reference_id) {
|
||||
ogs_error("OpenAPI_ec_restriction_parseFromJSON() failed [reference_id]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!cJSON_IsNumber(reference_id)) {
|
||||
ogs_error("OpenAPI_ec_restriction_parseFromJSON() failed [reference_id]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
cJSON *plmn_ec_infos = cJSON_GetObjectItemCaseSensitive(ec_restrictionJSON, "plmnEcInfos");
|
||||
|
||||
OpenAPI_list_t *plmn_ec_infosList;
|
||||
plmn_ec_infos = cJSON_GetObjectItemCaseSensitive(ec_restrictionJSON, "plmnEcInfos");
|
||||
if (plmn_ec_infos) {
|
||||
cJSON *plmn_ec_infos_local_nonprimitive;
|
||||
if (!cJSON_IsArray(plmn_ec_infos)){
|
||||
ogs_error("OpenAPI_ec_restriction_parseFromJSON() failed [plmn_ec_infos]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
plmn_ec_infosList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(plmn_ec_infos_local_nonprimitive, plmn_ec_infos ) {
|
||||
if (!cJSON_IsObject(plmn_ec_infos_local_nonprimitive)) {
|
||||
cJSON *plmn_ec_infos_local = NULL;
|
||||
if (!cJSON_IsArray(plmn_ec_infos)) {
|
||||
ogs_error("OpenAPI_ec_restriction_parseFromJSON() failed [plmn_ec_infos]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_plmn_ec_info_t *plmn_ec_infosItem = OpenAPI_plmn_ec_info_parseFromJSON(plmn_ec_infos_local_nonprimitive);
|
||||
|
||||
if (!plmn_ec_infosItem) {
|
||||
ogs_error("No plmn_ec_infosItem");
|
||||
OpenAPI_list_free(plmn_ec_infosList);
|
||||
goto end;
|
||||
plmn_ec_infosList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(plmn_ec_infos_local, plmn_ec_infos) {
|
||||
if (!cJSON_IsObject(plmn_ec_infos_local)) {
|
||||
ogs_error("OpenAPI_ec_restriction_parseFromJSON() failed [plmn_ec_infos]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_plmn_ec_info_t *plmn_ec_infosItem = OpenAPI_plmn_ec_info_parseFromJSON(plmn_ec_infos_local);
|
||||
if (!plmn_ec_infosItem) {
|
||||
ogs_error("No plmn_ec_infosItem");
|
||||
OpenAPI_list_free(plmn_ec_infosList);
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(plmn_ec_infosList, plmn_ec_infosItem);
|
||||
}
|
||||
|
||||
OpenAPI_list_add(plmn_ec_infosList, plmn_ec_infosItem);
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *mtc_provider_information = cJSON_GetObjectItemCaseSensitive(ec_restrictionJSON, "mtcProviderInformation");
|
||||
|
||||
mtc_provider_information = cJSON_GetObjectItemCaseSensitive(ec_restrictionJSON, "mtcProviderInformation");
|
||||
if (mtc_provider_information) {
|
||||
if (!cJSON_IsString(mtc_provider_information)) {
|
||||
if (!cJSON_IsString(mtc_provider_information) && !cJSON_IsNull(mtc_provider_information)) {
|
||||
ogs_error("OpenAPI_ec_restriction_parseFromJSON() failed [mtc_provider_information]");
|
||||
goto end;
|
||||
}
|
||||
|
|
@ -156,11 +166,18 @@ OpenAPI_ec_restriction_t *OpenAPI_ec_restriction_parseFromJSON(cJSON *ec_restric
|
|||
|
||||
reference_id->valuedouble,
|
||||
plmn_ec_infos ? plmn_ec_infosList : NULL,
|
||||
mtc_provider_information ? ogs_strdup(mtc_provider_information->valuestring) : NULL
|
||||
mtc_provider_information && !cJSON_IsNull(mtc_provider_information) ? ogs_strdup(mtc_provider_information->valuestring) : NULL
|
||||
);
|
||||
|
||||
return ec_restriction_local_var;
|
||||
end:
|
||||
if (plmn_ec_infosList) {
|
||||
OpenAPI_list_for_each(plmn_ec_infosList, node) {
|
||||
OpenAPI_plmn_ec_info_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(plmn_ec_infosList);
|
||||
plmn_ec_infosList = NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue