[SBI] Crash occurs when ENUM in the MAP (#2103)

This commit is contained in:
Sukchan Lee 2023-03-01 17:50:25 +09:00
parent ce668c556c
commit 969c116e77
1097 changed files with 266728 additions and 42047 deletions

View file

@ -28,31 +28,51 @@ OpenAPI_chf_info_t *OpenAPI_chf_info_create(
void OpenAPI_chf_info_free(OpenAPI_chf_info_t *chf_info)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == chf_info) {
return;
}
OpenAPI_lnode_t *node;
OpenAPI_list_for_each(chf_info->supi_range_list, node) {
OpenAPI_supi_range_free(node->data);
if (chf_info->supi_range_list) {
OpenAPI_list_for_each(chf_info->supi_range_list, node) {
OpenAPI_supi_range_free(node->data);
}
OpenAPI_list_free(chf_info->supi_range_list);
chf_info->supi_range_list = NULL;
}
OpenAPI_list_free(chf_info->supi_range_list);
OpenAPI_list_for_each(chf_info->gpsi_range_list, node) {
OpenAPI_identity_range_free(node->data);
if (chf_info->gpsi_range_list) {
OpenAPI_list_for_each(chf_info->gpsi_range_list, node) {
OpenAPI_identity_range_free(node->data);
}
OpenAPI_list_free(chf_info->gpsi_range_list);
chf_info->gpsi_range_list = NULL;
}
OpenAPI_list_free(chf_info->gpsi_range_list);
OpenAPI_list_for_each(chf_info->plmn_range_list, node) {
OpenAPI_plmn_range_free(node->data);
if (chf_info->plmn_range_list) {
OpenAPI_list_for_each(chf_info->plmn_range_list, node) {
OpenAPI_plmn_range_free(node->data);
}
OpenAPI_list_free(chf_info->plmn_range_list);
chf_info->plmn_range_list = NULL;
}
if (chf_info->group_id) {
ogs_free(chf_info->group_id);
chf_info->group_id = NULL;
}
if (chf_info->primary_chf_instance) {
ogs_free(chf_info->primary_chf_instance);
chf_info->primary_chf_instance = NULL;
}
if (chf_info->secondary_chf_instance) {
ogs_free(chf_info->secondary_chf_instance);
chf_info->secondary_chf_instance = NULL;
}
OpenAPI_list_free(chf_info->plmn_range_list);
ogs_free(chf_info->group_id);
ogs_free(chf_info->primary_chf_instance);
ogs_free(chf_info->secondary_chf_instance);
ogs_free(chf_info);
}
cJSON *OpenAPI_chf_info_convertToJSON(OpenAPI_chf_info_t *chf_info)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (chf_info == NULL) {
ogs_error("OpenAPI_chf_info_convertToJSON() failed [ChfInfo]");
@ -66,17 +86,13 @@ cJSON *OpenAPI_chf_info_convertToJSON(OpenAPI_chf_info_t *chf_info)
ogs_error("OpenAPI_chf_info_convertToJSON() failed [supi_range_list]");
goto end;
}
OpenAPI_lnode_t *supi_range_list_node;
if (chf_info->supi_range_list) {
OpenAPI_list_for_each(chf_info->supi_range_list, supi_range_list_node) {
cJSON *itemLocal = OpenAPI_supi_range_convertToJSON(supi_range_list_node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_chf_info_convertToJSON() failed [supi_range_list]");
goto end;
}
cJSON_AddItemToArray(supi_range_listList, itemLocal);
OpenAPI_list_for_each(chf_info->supi_range_list, node) {
cJSON *itemLocal = OpenAPI_supi_range_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_chf_info_convertToJSON() failed [supi_range_list]");
goto end;
}
cJSON_AddItemToArray(supi_range_listList, itemLocal);
}
}
@ -86,17 +102,13 @@ cJSON *OpenAPI_chf_info_convertToJSON(OpenAPI_chf_info_t *chf_info)
ogs_error("OpenAPI_chf_info_convertToJSON() failed [gpsi_range_list]");
goto end;
}
OpenAPI_lnode_t *gpsi_range_list_node;
if (chf_info->gpsi_range_list) {
OpenAPI_list_for_each(chf_info->gpsi_range_list, gpsi_range_list_node) {
cJSON *itemLocal = OpenAPI_identity_range_convertToJSON(gpsi_range_list_node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_chf_info_convertToJSON() failed [gpsi_range_list]");
goto end;
}
cJSON_AddItemToArray(gpsi_range_listList, itemLocal);
OpenAPI_list_for_each(chf_info->gpsi_range_list, node) {
cJSON *itemLocal = OpenAPI_identity_range_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_chf_info_convertToJSON() failed [gpsi_range_list]");
goto end;
}
cJSON_AddItemToArray(gpsi_range_listList, itemLocal);
}
}
@ -106,17 +118,13 @@ cJSON *OpenAPI_chf_info_convertToJSON(OpenAPI_chf_info_t *chf_info)
ogs_error("OpenAPI_chf_info_convertToJSON() failed [plmn_range_list]");
goto end;
}
OpenAPI_lnode_t *plmn_range_list_node;
if (chf_info->plmn_range_list) {
OpenAPI_list_for_each(chf_info->plmn_range_list, plmn_range_list_node) {
cJSON *itemLocal = OpenAPI_plmn_range_convertToJSON(plmn_range_list_node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_chf_info_convertToJSON() failed [plmn_range_list]");
goto end;
}
cJSON_AddItemToArray(plmn_range_listList, itemLocal);
OpenAPI_list_for_each(chf_info->plmn_range_list, node) {
cJSON *itemLocal = OpenAPI_plmn_range_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_chf_info_convertToJSON() failed [plmn_range_list]");
goto end;
}
cJSON_AddItemToArray(plmn_range_listList, itemLocal);
}
}
@ -148,115 +156,110 @@ end:
OpenAPI_chf_info_t *OpenAPI_chf_info_parseFromJSON(cJSON *chf_infoJSON)
{
OpenAPI_chf_info_t *chf_info_local_var = NULL;
cJSON *supi_range_list = cJSON_GetObjectItemCaseSensitive(chf_infoJSON, "supiRangeList");
OpenAPI_list_t *supi_range_listList;
OpenAPI_lnode_t *node = NULL;
cJSON *supi_range_list = NULL;
OpenAPI_list_t *supi_range_listList = NULL;
cJSON *gpsi_range_list = NULL;
OpenAPI_list_t *gpsi_range_listList = NULL;
cJSON *plmn_range_list = NULL;
OpenAPI_list_t *plmn_range_listList = NULL;
cJSON *group_id = NULL;
cJSON *primary_chf_instance = NULL;
cJSON *secondary_chf_instance = NULL;
supi_range_list = cJSON_GetObjectItemCaseSensitive(chf_infoJSON, "supiRangeList");
if (supi_range_list) {
cJSON *supi_range_list_local_nonprimitive;
if (!cJSON_IsArray(supi_range_list)){
ogs_error("OpenAPI_chf_info_parseFromJSON() failed [supi_range_list]");
goto end;
}
supi_range_listList = OpenAPI_list_create();
cJSON_ArrayForEach(supi_range_list_local_nonprimitive, supi_range_list ) {
if (!cJSON_IsObject(supi_range_list_local_nonprimitive)) {
cJSON *supi_range_list_local = NULL;
if (!cJSON_IsArray(supi_range_list)) {
ogs_error("OpenAPI_chf_info_parseFromJSON() failed [supi_range_list]");
goto end;
}
OpenAPI_supi_range_t *supi_range_listItem = OpenAPI_supi_range_parseFromJSON(supi_range_list_local_nonprimitive);
if (!supi_range_listItem) {
ogs_error("No supi_range_listItem");
OpenAPI_list_free(supi_range_listList);
goto end;
supi_range_listList = OpenAPI_list_create();
cJSON_ArrayForEach(supi_range_list_local, supi_range_list) {
if (!cJSON_IsObject(supi_range_list_local)) {
ogs_error("OpenAPI_chf_info_parseFromJSON() failed [supi_range_list]");
goto end;
}
OpenAPI_supi_range_t *supi_range_listItem = OpenAPI_supi_range_parseFromJSON(supi_range_list_local);
if (!supi_range_listItem) {
ogs_error("No supi_range_listItem");
OpenAPI_list_free(supi_range_listList);
goto end;
}
OpenAPI_list_add(supi_range_listList, supi_range_listItem);
}
OpenAPI_list_add(supi_range_listList, supi_range_listItem);
}
}
cJSON *gpsi_range_list = cJSON_GetObjectItemCaseSensitive(chf_infoJSON, "gpsiRangeList");
OpenAPI_list_t *gpsi_range_listList;
gpsi_range_list = cJSON_GetObjectItemCaseSensitive(chf_infoJSON, "gpsiRangeList");
if (gpsi_range_list) {
cJSON *gpsi_range_list_local_nonprimitive;
if (!cJSON_IsArray(gpsi_range_list)){
ogs_error("OpenAPI_chf_info_parseFromJSON() failed [gpsi_range_list]");
goto end;
}
gpsi_range_listList = OpenAPI_list_create();
cJSON_ArrayForEach(gpsi_range_list_local_nonprimitive, gpsi_range_list ) {
if (!cJSON_IsObject(gpsi_range_list_local_nonprimitive)) {
cJSON *gpsi_range_list_local = NULL;
if (!cJSON_IsArray(gpsi_range_list)) {
ogs_error("OpenAPI_chf_info_parseFromJSON() failed [gpsi_range_list]");
goto end;
}
OpenAPI_identity_range_t *gpsi_range_listItem = OpenAPI_identity_range_parseFromJSON(gpsi_range_list_local_nonprimitive);
if (!gpsi_range_listItem) {
ogs_error("No gpsi_range_listItem");
OpenAPI_list_free(gpsi_range_listList);
goto end;
gpsi_range_listList = OpenAPI_list_create();
cJSON_ArrayForEach(gpsi_range_list_local, gpsi_range_list) {
if (!cJSON_IsObject(gpsi_range_list_local)) {
ogs_error("OpenAPI_chf_info_parseFromJSON() failed [gpsi_range_list]");
goto end;
}
OpenAPI_identity_range_t *gpsi_range_listItem = OpenAPI_identity_range_parseFromJSON(gpsi_range_list_local);
if (!gpsi_range_listItem) {
ogs_error("No gpsi_range_listItem");
OpenAPI_list_free(gpsi_range_listList);
goto end;
}
OpenAPI_list_add(gpsi_range_listList, gpsi_range_listItem);
}
OpenAPI_list_add(gpsi_range_listList, gpsi_range_listItem);
}
}
cJSON *plmn_range_list = cJSON_GetObjectItemCaseSensitive(chf_infoJSON, "plmnRangeList");
OpenAPI_list_t *plmn_range_listList;
plmn_range_list = cJSON_GetObjectItemCaseSensitive(chf_infoJSON, "plmnRangeList");
if (plmn_range_list) {
cJSON *plmn_range_list_local_nonprimitive;
if (!cJSON_IsArray(plmn_range_list)){
ogs_error("OpenAPI_chf_info_parseFromJSON() failed [plmn_range_list]");
goto end;
}
plmn_range_listList = OpenAPI_list_create();
cJSON_ArrayForEach(plmn_range_list_local_nonprimitive, plmn_range_list ) {
if (!cJSON_IsObject(plmn_range_list_local_nonprimitive)) {
cJSON *plmn_range_list_local = NULL;
if (!cJSON_IsArray(plmn_range_list)) {
ogs_error("OpenAPI_chf_info_parseFromJSON() failed [plmn_range_list]");
goto end;
}
OpenAPI_plmn_range_t *plmn_range_listItem = OpenAPI_plmn_range_parseFromJSON(plmn_range_list_local_nonprimitive);
if (!plmn_range_listItem) {
ogs_error("No plmn_range_listItem");
OpenAPI_list_free(plmn_range_listList);
goto end;
plmn_range_listList = OpenAPI_list_create();
cJSON_ArrayForEach(plmn_range_list_local, plmn_range_list) {
if (!cJSON_IsObject(plmn_range_list_local)) {
ogs_error("OpenAPI_chf_info_parseFromJSON() failed [plmn_range_list]");
goto end;
}
OpenAPI_plmn_range_t *plmn_range_listItem = OpenAPI_plmn_range_parseFromJSON(plmn_range_list_local);
if (!plmn_range_listItem) {
ogs_error("No plmn_range_listItem");
OpenAPI_list_free(plmn_range_listList);
goto end;
}
OpenAPI_list_add(plmn_range_listList, plmn_range_listItem);
}
OpenAPI_list_add(plmn_range_listList, plmn_range_listItem);
}
}
cJSON *group_id = cJSON_GetObjectItemCaseSensitive(chf_infoJSON, "groupId");
group_id = cJSON_GetObjectItemCaseSensitive(chf_infoJSON, "groupId");
if (group_id) {
if (!cJSON_IsString(group_id)) {
if (!cJSON_IsString(group_id) && !cJSON_IsNull(group_id)) {
ogs_error("OpenAPI_chf_info_parseFromJSON() failed [group_id]");
goto end;
}
}
cJSON *primary_chf_instance = cJSON_GetObjectItemCaseSensitive(chf_infoJSON, "primaryChfInstance");
primary_chf_instance = cJSON_GetObjectItemCaseSensitive(chf_infoJSON, "primaryChfInstance");
if (primary_chf_instance) {
if (!cJSON_IsString(primary_chf_instance)) {
if (!cJSON_IsString(primary_chf_instance) && !cJSON_IsNull(primary_chf_instance)) {
ogs_error("OpenAPI_chf_info_parseFromJSON() failed [primary_chf_instance]");
goto end;
}
}
cJSON *secondary_chf_instance = cJSON_GetObjectItemCaseSensitive(chf_infoJSON, "secondaryChfInstance");
secondary_chf_instance = cJSON_GetObjectItemCaseSensitive(chf_infoJSON, "secondaryChfInstance");
if (secondary_chf_instance) {
if (!cJSON_IsString(secondary_chf_instance)) {
if (!cJSON_IsString(secondary_chf_instance) && !cJSON_IsNull(secondary_chf_instance)) {
ogs_error("OpenAPI_chf_info_parseFromJSON() failed [secondary_chf_instance]");
goto end;
}
@ -266,13 +269,34 @@ OpenAPI_chf_info_t *OpenAPI_chf_info_parseFromJSON(cJSON *chf_infoJSON)
supi_range_list ? supi_range_listList : NULL,
gpsi_range_list ? gpsi_range_listList : NULL,
plmn_range_list ? plmn_range_listList : NULL,
group_id ? ogs_strdup(group_id->valuestring) : NULL,
primary_chf_instance ? ogs_strdup(primary_chf_instance->valuestring) : NULL,
secondary_chf_instance ? ogs_strdup(secondary_chf_instance->valuestring) : NULL
group_id && !cJSON_IsNull(group_id) ? ogs_strdup(group_id->valuestring) : NULL,
primary_chf_instance && !cJSON_IsNull(primary_chf_instance) ? ogs_strdup(primary_chf_instance->valuestring) : NULL,
secondary_chf_instance && !cJSON_IsNull(secondary_chf_instance) ? ogs_strdup(secondary_chf_instance->valuestring) : NULL
);
return chf_info_local_var;
end:
if (supi_range_listList) {
OpenAPI_list_for_each(supi_range_listList, node) {
OpenAPI_supi_range_free(node->data);
}
OpenAPI_list_free(supi_range_listList);
supi_range_listList = NULL;
}
if (gpsi_range_listList) {
OpenAPI_list_for_each(gpsi_range_listList, node) {
OpenAPI_identity_range_free(node->data);
}
OpenAPI_list_free(gpsi_range_listList);
gpsi_range_listList = NULL;
}
if (plmn_range_listList) {
OpenAPI_list_for_each(plmn_range_listList, node) {
OpenAPI_plmn_range_free(node->data);
}
OpenAPI_list_free(plmn_range_listList);
plmn_range_listList = NULL;
}
return NULL;
}