[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,22 +28,33 @@ OpenAPI_sm_context_retrieve_data_t *OpenAPI_sm_context_retrieve_data_create(
void OpenAPI_sm_context_retrieve_data_free(OpenAPI_sm_context_retrieve_data_t *sm_context_retrieve_data)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == sm_context_retrieve_data) {
return;
}
OpenAPI_lnode_t *node;
OpenAPI_mme_capabilities_free(sm_context_retrieve_data->target_mme_cap);
OpenAPI_plmn_id_free(sm_context_retrieve_data->serving_network);
OpenAPI_list_for_each(sm_context_retrieve_data->not_to_transfer_ebi_list, node) {
ogs_free(node->data);
if (sm_context_retrieve_data->target_mme_cap) {
OpenAPI_mme_capabilities_free(sm_context_retrieve_data->target_mme_cap);
sm_context_retrieve_data->target_mme_cap = NULL;
}
if (sm_context_retrieve_data->serving_network) {
OpenAPI_plmn_id_free(sm_context_retrieve_data->serving_network);
sm_context_retrieve_data->serving_network = NULL;
}
if (sm_context_retrieve_data->not_to_transfer_ebi_list) {
OpenAPI_list_for_each(sm_context_retrieve_data->not_to_transfer_ebi_list, node) {
ogs_free(node->data);
}
OpenAPI_list_free(sm_context_retrieve_data->not_to_transfer_ebi_list);
sm_context_retrieve_data->not_to_transfer_ebi_list = NULL;
}
OpenAPI_list_free(sm_context_retrieve_data->not_to_transfer_ebi_list);
ogs_free(sm_context_retrieve_data);
}
cJSON *OpenAPI_sm_context_retrieve_data_convertToJSON(OpenAPI_sm_context_retrieve_data_t *sm_context_retrieve_data)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (sm_context_retrieve_data == NULL) {
ogs_error("OpenAPI_sm_context_retrieve_data_convertToJSON() failed [SmContextRetrieveData]");
@ -64,7 +75,7 @@ cJSON *OpenAPI_sm_context_retrieve_data_convertToJSON(OpenAPI_sm_context_retriev
}
}
if (sm_context_retrieve_data->sm_context_type) {
if (sm_context_retrieve_data->sm_context_type != OpenAPI_sm_context_type_NULL) {
if (cJSON_AddStringToObject(item, "smContextType", OpenAPI_sm_context_type_ToString(sm_context_retrieve_data->sm_context_type)) == NULL) {
ogs_error("OpenAPI_sm_context_retrieve_data_convertToJSON() failed [sm_context_type]");
goto end;
@ -85,19 +96,17 @@ cJSON *OpenAPI_sm_context_retrieve_data_convertToJSON(OpenAPI_sm_context_retriev
}
if (sm_context_retrieve_data->not_to_transfer_ebi_list) {
cJSON *not_to_transfer_ebi_list = cJSON_AddArrayToObject(item, "notToTransferEbiList");
if (not_to_transfer_ebi_list == NULL) {
cJSON *not_to_transfer_ebi_listList = cJSON_AddArrayToObject(item, "notToTransferEbiList");
if (not_to_transfer_ebi_listList == NULL) {
ogs_error("OpenAPI_sm_context_retrieve_data_convertToJSON() failed [not_to_transfer_ebi_list]");
goto end;
}
OpenAPI_lnode_t *not_to_transfer_ebi_list_node;
OpenAPI_list_for_each(sm_context_retrieve_data->not_to_transfer_ebi_list, not_to_transfer_ebi_list_node) {
if (cJSON_AddNumberToObject(not_to_transfer_ebi_list, "", *(double *)not_to_transfer_ebi_list_node->data) == NULL) {
ogs_error("OpenAPI_sm_context_retrieve_data_convertToJSON() failed [not_to_transfer_ebi_list]");
goto end;
OpenAPI_list_for_each(sm_context_retrieve_data->not_to_transfer_ebi_list, node) {
if (cJSON_AddNumberToObject(not_to_transfer_ebi_listList, "", (uintptr_t)node->data) == NULL) {
ogs_error("OpenAPI_sm_context_retrieve_data_convertToJSON() failed [not_to_transfer_ebi_list]");
goto end;
}
}
}
}
if (sm_context_retrieve_data->is_ran_unchanged_ind) {
@ -114,16 +123,22 @@ end:
OpenAPI_sm_context_retrieve_data_t *OpenAPI_sm_context_retrieve_data_parseFromJSON(cJSON *sm_context_retrieve_dataJSON)
{
OpenAPI_sm_context_retrieve_data_t *sm_context_retrieve_data_local_var = NULL;
cJSON *target_mme_cap = cJSON_GetObjectItemCaseSensitive(sm_context_retrieve_dataJSON, "targetMmeCap");
OpenAPI_lnode_t *node = NULL;
cJSON *target_mme_cap = NULL;
OpenAPI_mme_capabilities_t *target_mme_cap_local_nonprim = NULL;
cJSON *sm_context_type = NULL;
OpenAPI_sm_context_type_e sm_context_typeVariable = 0;
cJSON *serving_network = NULL;
OpenAPI_plmn_id_t *serving_network_local_nonprim = NULL;
cJSON *not_to_transfer_ebi_list = NULL;
OpenAPI_list_t *not_to_transfer_ebi_listList = NULL;
cJSON *ran_unchanged_ind = NULL;
target_mme_cap = cJSON_GetObjectItemCaseSensitive(sm_context_retrieve_dataJSON, "targetMmeCap");
if (target_mme_cap) {
target_mme_cap_local_nonprim = OpenAPI_mme_capabilities_parseFromJSON(target_mme_cap);
}
cJSON *sm_context_type = cJSON_GetObjectItemCaseSensitive(sm_context_retrieve_dataJSON, "smContextType");
OpenAPI_sm_context_type_e sm_context_typeVariable;
sm_context_type = cJSON_GetObjectItemCaseSensitive(sm_context_retrieve_dataJSON, "smContextType");
if (sm_context_type) {
if (!cJSON_IsString(sm_context_type)) {
ogs_error("OpenAPI_sm_context_retrieve_data_parseFromJSON() failed [sm_context_type]");
@ -132,35 +147,39 @@ OpenAPI_sm_context_retrieve_data_t *OpenAPI_sm_context_retrieve_data_parseFromJS
sm_context_typeVariable = OpenAPI_sm_context_type_FromString(sm_context_type->valuestring);
}
cJSON *serving_network = cJSON_GetObjectItemCaseSensitive(sm_context_retrieve_dataJSON, "servingNetwork");
OpenAPI_plmn_id_t *serving_network_local_nonprim = NULL;
serving_network = cJSON_GetObjectItemCaseSensitive(sm_context_retrieve_dataJSON, "servingNetwork");
if (serving_network) {
serving_network_local_nonprim = OpenAPI_plmn_id_parseFromJSON(serving_network);
}
cJSON *not_to_transfer_ebi_list = cJSON_GetObjectItemCaseSensitive(sm_context_retrieve_dataJSON, "notToTransferEbiList");
OpenAPI_list_t *not_to_transfer_ebi_listList;
not_to_transfer_ebi_list = cJSON_GetObjectItemCaseSensitive(sm_context_retrieve_dataJSON, "notToTransferEbiList");
if (not_to_transfer_ebi_list) {
cJSON *not_to_transfer_ebi_list_local;
if (!cJSON_IsArray(not_to_transfer_ebi_list)) {
ogs_error("OpenAPI_sm_context_retrieve_data_parseFromJSON() failed [not_to_transfer_ebi_list]");
goto end;
}
not_to_transfer_ebi_listList = OpenAPI_list_create();
cJSON *not_to_transfer_ebi_list_local = NULL;
if (!cJSON_IsArray(not_to_transfer_ebi_list)) {
ogs_error("OpenAPI_sm_context_retrieve_data_parseFromJSON() failed [not_to_transfer_ebi_list]");
goto end;
}
cJSON_ArrayForEach(not_to_transfer_ebi_list_local, not_to_transfer_ebi_list) {
if (!cJSON_IsNumber(not_to_transfer_ebi_list_local)) {
ogs_error("OpenAPI_sm_context_retrieve_data_parseFromJSON() failed [not_to_transfer_ebi_list]");
goto end;
}
OpenAPI_list_add(not_to_transfer_ebi_listList, &not_to_transfer_ebi_list_local->valuedouble);
}
not_to_transfer_ebi_listList = OpenAPI_list_create();
cJSON_ArrayForEach(not_to_transfer_ebi_list_local, not_to_transfer_ebi_list) {
double *localDouble = NULL;
int *localInt = NULL;
if (!cJSON_IsNumber(not_to_transfer_ebi_list_local)) {
ogs_error("OpenAPI_sm_context_retrieve_data_parseFromJSON() failed [not_to_transfer_ebi_list]");
goto end;
}
localDouble = (double *)ogs_calloc(1, sizeof(double));
if (!localDouble) {
ogs_error("OpenAPI_sm_context_retrieve_data_parseFromJSON() failed [not_to_transfer_ebi_list]");
goto end;
}
*localDouble = not_to_transfer_ebi_list_local->valuedouble;
OpenAPI_list_add(not_to_transfer_ebi_listList, localDouble);
}
}
cJSON *ran_unchanged_ind = cJSON_GetObjectItemCaseSensitive(sm_context_retrieve_dataJSON, "ranUnchangedInd");
ran_unchanged_ind = cJSON_GetObjectItemCaseSensitive(sm_context_retrieve_dataJSON, "ranUnchangedInd");
if (ran_unchanged_ind) {
if (!cJSON_IsBool(ran_unchanged_ind)) {
ogs_error("OpenAPI_sm_context_retrieve_data_parseFromJSON() failed [ran_unchanged_ind]");
@ -179,6 +198,21 @@ OpenAPI_sm_context_retrieve_data_t *OpenAPI_sm_context_retrieve_data_parseFromJS
return sm_context_retrieve_data_local_var;
end:
if (target_mme_cap_local_nonprim) {
OpenAPI_mme_capabilities_free(target_mme_cap_local_nonprim);
target_mme_cap_local_nonprim = NULL;
}
if (serving_network_local_nonprim) {
OpenAPI_plmn_id_free(serving_network_local_nonprim);
serving_network_local_nonprim = NULL;
}
if (not_to_transfer_ebi_listList) {
OpenAPI_list_for_each(not_to_transfer_ebi_listList, node) {
ogs_free(node->data);
}
OpenAPI_list_free(not_to_transfer_ebi_listList);
not_to_transfer_ebi_listList = NULL;
}
return NULL;
}