[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

@ -5,7 +5,7 @@
#include "vn_group_data.h"
OpenAPI_vn_group_data_t *OpenAPI_vn_group_data_create(
OpenAPI_pdu_session_types_1_t *pdu_session_types,
OpenAPI_pdu_session_types_t *pdu_session_types,
char *dnn,
OpenAPI_snssai_t *single_nssai,
OpenAPI_list_t *app_descriptors
@ -24,23 +24,37 @@ OpenAPI_vn_group_data_t *OpenAPI_vn_group_data_create(
void OpenAPI_vn_group_data_free(OpenAPI_vn_group_data_t *vn_group_data)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == vn_group_data) {
return;
}
OpenAPI_lnode_t *node;
OpenAPI_pdu_session_types_1_free(vn_group_data->pdu_session_types);
ogs_free(vn_group_data->dnn);
OpenAPI_snssai_free(vn_group_data->single_nssai);
OpenAPI_list_for_each(vn_group_data->app_descriptors, node) {
OpenAPI_app_descriptor_free(node->data);
if (vn_group_data->pdu_session_types) {
OpenAPI_pdu_session_types_free(vn_group_data->pdu_session_types);
vn_group_data->pdu_session_types = NULL;
}
if (vn_group_data->dnn) {
ogs_free(vn_group_data->dnn);
vn_group_data->dnn = NULL;
}
if (vn_group_data->single_nssai) {
OpenAPI_snssai_free(vn_group_data->single_nssai);
vn_group_data->single_nssai = NULL;
}
if (vn_group_data->app_descriptors) {
OpenAPI_list_for_each(vn_group_data->app_descriptors, node) {
OpenAPI_app_descriptor_free(node->data);
}
OpenAPI_list_free(vn_group_data->app_descriptors);
vn_group_data->app_descriptors = NULL;
}
OpenAPI_list_free(vn_group_data->app_descriptors);
ogs_free(vn_group_data);
}
cJSON *OpenAPI_vn_group_data_convertToJSON(OpenAPI_vn_group_data_t *vn_group_data)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (vn_group_data == NULL) {
ogs_error("OpenAPI_vn_group_data_convertToJSON() failed [VnGroupData]");
@ -49,7 +63,7 @@ cJSON *OpenAPI_vn_group_data_convertToJSON(OpenAPI_vn_group_data_t *vn_group_dat
item = cJSON_CreateObject();
if (vn_group_data->pdu_session_types) {
cJSON *pdu_session_types_local_JSON = OpenAPI_pdu_session_types_1_convertToJSON(vn_group_data->pdu_session_types);
cJSON *pdu_session_types_local_JSON = OpenAPI_pdu_session_types_convertToJSON(vn_group_data->pdu_session_types);
if (pdu_session_types_local_JSON == NULL) {
ogs_error("OpenAPI_vn_group_data_convertToJSON() failed [pdu_session_types]");
goto end;
@ -87,17 +101,13 @@ cJSON *OpenAPI_vn_group_data_convertToJSON(OpenAPI_vn_group_data_t *vn_group_dat
ogs_error("OpenAPI_vn_group_data_convertToJSON() failed [app_descriptors]");
goto end;
}
OpenAPI_lnode_t *app_descriptors_node;
if (vn_group_data->app_descriptors) {
OpenAPI_list_for_each(vn_group_data->app_descriptors, app_descriptors_node) {
cJSON *itemLocal = OpenAPI_app_descriptor_convertToJSON(app_descriptors_node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_vn_group_data_convertToJSON() failed [app_descriptors]");
goto end;
}
cJSON_AddItemToArray(app_descriptorsList, itemLocal);
OpenAPI_list_for_each(vn_group_data->app_descriptors, node) {
cJSON *itemLocal = OpenAPI_app_descriptor_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_vn_group_data_convertToJSON() failed [app_descriptors]");
goto end;
}
cJSON_AddItemToArray(app_descriptorsList, itemLocal);
}
}
@ -108,67 +118,81 @@ end:
OpenAPI_vn_group_data_t *OpenAPI_vn_group_data_parseFromJSON(cJSON *vn_group_dataJSON)
{
OpenAPI_vn_group_data_t *vn_group_data_local_var = NULL;
cJSON *pdu_session_types = cJSON_GetObjectItemCaseSensitive(vn_group_dataJSON, "pduSessionTypes");
OpenAPI_pdu_session_types_1_t *pdu_session_types_local_nonprim = NULL;
OpenAPI_lnode_t *node = NULL;
cJSON *pdu_session_types = NULL;
OpenAPI_pdu_session_types_t *pdu_session_types_local_nonprim = NULL;
cJSON *dnn = NULL;
cJSON *single_nssai = NULL;
OpenAPI_snssai_t *single_nssai_local_nonprim = NULL;
cJSON *app_descriptors = NULL;
OpenAPI_list_t *app_descriptorsList = NULL;
pdu_session_types = cJSON_GetObjectItemCaseSensitive(vn_group_dataJSON, "pduSessionTypes");
if (pdu_session_types) {
pdu_session_types_local_nonprim = OpenAPI_pdu_session_types_1_parseFromJSON(pdu_session_types);
pdu_session_types_local_nonprim = OpenAPI_pdu_session_types_parseFromJSON(pdu_session_types);
}
cJSON *dnn = cJSON_GetObjectItemCaseSensitive(vn_group_dataJSON, "dnn");
dnn = cJSON_GetObjectItemCaseSensitive(vn_group_dataJSON, "dnn");
if (dnn) {
if (!cJSON_IsString(dnn)) {
if (!cJSON_IsString(dnn) && !cJSON_IsNull(dnn)) {
ogs_error("OpenAPI_vn_group_data_parseFromJSON() failed [dnn]");
goto end;
}
}
cJSON *single_nssai = cJSON_GetObjectItemCaseSensitive(vn_group_dataJSON, "singleNssai");
OpenAPI_snssai_t *single_nssai_local_nonprim = NULL;
single_nssai = cJSON_GetObjectItemCaseSensitive(vn_group_dataJSON, "singleNssai");
if (single_nssai) {
single_nssai_local_nonprim = OpenAPI_snssai_parseFromJSON(single_nssai);
}
cJSON *app_descriptors = cJSON_GetObjectItemCaseSensitive(vn_group_dataJSON, "appDescriptors");
OpenAPI_list_t *app_descriptorsList;
app_descriptors = cJSON_GetObjectItemCaseSensitive(vn_group_dataJSON, "appDescriptors");
if (app_descriptors) {
cJSON *app_descriptors_local_nonprimitive;
if (!cJSON_IsArray(app_descriptors)){
ogs_error("OpenAPI_vn_group_data_parseFromJSON() failed [app_descriptors]");
goto end;
}
app_descriptorsList = OpenAPI_list_create();
cJSON_ArrayForEach(app_descriptors_local_nonprimitive, app_descriptors ) {
if (!cJSON_IsObject(app_descriptors_local_nonprimitive)) {
cJSON *app_descriptors_local = NULL;
if (!cJSON_IsArray(app_descriptors)) {
ogs_error("OpenAPI_vn_group_data_parseFromJSON() failed [app_descriptors]");
goto end;
}
OpenAPI_app_descriptor_t *app_descriptorsItem = OpenAPI_app_descriptor_parseFromJSON(app_descriptors_local_nonprimitive);
if (!app_descriptorsItem) {
ogs_error("No app_descriptorsItem");
OpenAPI_list_free(app_descriptorsList);
goto end;
app_descriptorsList = OpenAPI_list_create();
cJSON_ArrayForEach(app_descriptors_local, app_descriptors) {
if (!cJSON_IsObject(app_descriptors_local)) {
ogs_error("OpenAPI_vn_group_data_parseFromJSON() failed [app_descriptors]");
goto end;
}
OpenAPI_app_descriptor_t *app_descriptorsItem = OpenAPI_app_descriptor_parseFromJSON(app_descriptors_local);
if (!app_descriptorsItem) {
ogs_error("No app_descriptorsItem");
OpenAPI_list_free(app_descriptorsList);
goto end;
}
OpenAPI_list_add(app_descriptorsList, app_descriptorsItem);
}
OpenAPI_list_add(app_descriptorsList, app_descriptorsItem);
}
}
vn_group_data_local_var = OpenAPI_vn_group_data_create (
pdu_session_types ? pdu_session_types_local_nonprim : NULL,
dnn ? ogs_strdup(dnn->valuestring) : NULL,
dnn && !cJSON_IsNull(dnn) ? ogs_strdup(dnn->valuestring) : NULL,
single_nssai ? single_nssai_local_nonprim : NULL,
app_descriptors ? app_descriptorsList : NULL
);
return vn_group_data_local_var;
end:
if (pdu_session_types_local_nonprim) {
OpenAPI_pdu_session_types_free(pdu_session_types_local_nonprim);
pdu_session_types_local_nonprim = NULL;
}
if (single_nssai_local_nonprim) {
OpenAPI_snssai_free(single_nssai_local_nonprim);
single_nssai_local_nonprim = NULL;
}
if (app_descriptorsList) {
OpenAPI_list_for_each(app_descriptorsList, node) {
OpenAPI_app_descriptor_free(node->data);
}
OpenAPI_list_free(app_descriptorsList);
app_descriptorsList = NULL;
}
return NULL;
}