[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

@ -22,25 +22,36 @@ OpenAPI_ausf_info_t *OpenAPI_ausf_info_create(
void OpenAPI_ausf_info_free(OpenAPI_ausf_info_t *ausf_info)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == ausf_info) {
return;
}
OpenAPI_lnode_t *node;
ogs_free(ausf_info->group_id);
OpenAPI_list_for_each(ausf_info->supi_ranges, node) {
OpenAPI_supi_range_free(node->data);
if (ausf_info->group_id) {
ogs_free(ausf_info->group_id);
ausf_info->group_id = NULL;
}
OpenAPI_list_free(ausf_info->supi_ranges);
OpenAPI_list_for_each(ausf_info->routing_indicators, node) {
ogs_free(node->data);
if (ausf_info->supi_ranges) {
OpenAPI_list_for_each(ausf_info->supi_ranges, node) {
OpenAPI_supi_range_free(node->data);
}
OpenAPI_list_free(ausf_info->supi_ranges);
ausf_info->supi_ranges = NULL;
}
if (ausf_info->routing_indicators) {
OpenAPI_list_for_each(ausf_info->routing_indicators, node) {
ogs_free(node->data);
}
OpenAPI_list_free(ausf_info->routing_indicators);
ausf_info->routing_indicators = NULL;
}
OpenAPI_list_free(ausf_info->routing_indicators);
ogs_free(ausf_info);
}
cJSON *OpenAPI_ausf_info_convertToJSON(OpenAPI_ausf_info_t *ausf_info)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (ausf_info == NULL) {
ogs_error("OpenAPI_ausf_info_convertToJSON() failed [AusfInfo]");
@ -61,34 +72,28 @@ cJSON *OpenAPI_ausf_info_convertToJSON(OpenAPI_ausf_info_t *ausf_info)
ogs_error("OpenAPI_ausf_info_convertToJSON() failed [supi_ranges]");
goto end;
}
OpenAPI_lnode_t *supi_ranges_node;
if (ausf_info->supi_ranges) {
OpenAPI_list_for_each(ausf_info->supi_ranges, supi_ranges_node) {
cJSON *itemLocal = OpenAPI_supi_range_convertToJSON(supi_ranges_node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_ausf_info_convertToJSON() failed [supi_ranges]");
goto end;
}
cJSON_AddItemToArray(supi_rangesList, itemLocal);
OpenAPI_list_for_each(ausf_info->supi_ranges, node) {
cJSON *itemLocal = OpenAPI_supi_range_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_ausf_info_convertToJSON() failed [supi_ranges]");
goto end;
}
cJSON_AddItemToArray(supi_rangesList, itemLocal);
}
}
if (ausf_info->routing_indicators) {
cJSON *routing_indicators = cJSON_AddArrayToObject(item, "routingIndicators");
if (routing_indicators == NULL) {
cJSON *routing_indicatorsList = cJSON_AddArrayToObject(item, "routingIndicators");
if (routing_indicatorsList == NULL) {
ogs_error("OpenAPI_ausf_info_convertToJSON() failed [routing_indicators]");
goto end;
}
OpenAPI_lnode_t *routing_indicators_node;
OpenAPI_list_for_each(ausf_info->routing_indicators, routing_indicators_node) {
if (cJSON_AddStringToObject(routing_indicators, "", (char*)routing_indicators_node->data) == NULL) {
ogs_error("OpenAPI_ausf_info_convertToJSON() failed [routing_indicators]");
goto end;
OpenAPI_list_for_each(ausf_info->routing_indicators, node) {
if (cJSON_AddStringToObject(routing_indicatorsList, "", (char*)node->data) == NULL) {
ogs_error("OpenAPI_ausf_info_convertToJSON() failed [routing_indicators]");
goto end;
}
}
}
}
end:
@ -98,72 +103,88 @@ end:
OpenAPI_ausf_info_t *OpenAPI_ausf_info_parseFromJSON(cJSON *ausf_infoJSON)
{
OpenAPI_ausf_info_t *ausf_info_local_var = NULL;
cJSON *group_id = cJSON_GetObjectItemCaseSensitive(ausf_infoJSON, "groupId");
OpenAPI_lnode_t *node = NULL;
cJSON *group_id = NULL;
cJSON *supi_ranges = NULL;
OpenAPI_list_t *supi_rangesList = NULL;
cJSON *routing_indicators = NULL;
OpenAPI_list_t *routing_indicatorsList = NULL;
group_id = cJSON_GetObjectItemCaseSensitive(ausf_infoJSON, "groupId");
if (group_id) {
if (!cJSON_IsString(group_id)) {
if (!cJSON_IsString(group_id) && !cJSON_IsNull(group_id)) {
ogs_error("OpenAPI_ausf_info_parseFromJSON() failed [group_id]");
goto end;
}
}
cJSON *supi_ranges = cJSON_GetObjectItemCaseSensitive(ausf_infoJSON, "supiRanges");
OpenAPI_list_t *supi_rangesList;
supi_ranges = cJSON_GetObjectItemCaseSensitive(ausf_infoJSON, "supiRanges");
if (supi_ranges) {
cJSON *supi_ranges_local_nonprimitive;
if (!cJSON_IsArray(supi_ranges)){
ogs_error("OpenAPI_ausf_info_parseFromJSON() failed [supi_ranges]");
goto end;
}
supi_rangesList = OpenAPI_list_create();
cJSON_ArrayForEach(supi_ranges_local_nonprimitive, supi_ranges ) {
if (!cJSON_IsObject(supi_ranges_local_nonprimitive)) {
cJSON *supi_ranges_local = NULL;
if (!cJSON_IsArray(supi_ranges)) {
ogs_error("OpenAPI_ausf_info_parseFromJSON() failed [supi_ranges]");
goto end;
}
OpenAPI_supi_range_t *supi_rangesItem = OpenAPI_supi_range_parseFromJSON(supi_ranges_local_nonprimitive);
if (!supi_rangesItem) {
ogs_error("No supi_rangesItem");
OpenAPI_list_free(supi_rangesList);
supi_rangesList = OpenAPI_list_create();
cJSON_ArrayForEach(supi_ranges_local, supi_ranges) {
if (!cJSON_IsObject(supi_ranges_local)) {
ogs_error("OpenAPI_ausf_info_parseFromJSON() failed [supi_ranges]");
goto end;
}
OpenAPI_supi_range_t *supi_rangesItem = OpenAPI_supi_range_parseFromJSON(supi_ranges_local);
if (!supi_rangesItem) {
ogs_error("No supi_rangesItem");
OpenAPI_list_free(supi_rangesList);
goto end;
}
OpenAPI_list_add(supi_rangesList, supi_rangesItem);
}
}
routing_indicators = cJSON_GetObjectItemCaseSensitive(ausf_infoJSON, "routingIndicators");
if (routing_indicators) {
cJSON *routing_indicators_local = NULL;
if (!cJSON_IsArray(routing_indicators)) {
ogs_error("OpenAPI_ausf_info_parseFromJSON() failed [routing_indicators]");
goto end;
}
OpenAPI_list_add(supi_rangesList, supi_rangesItem);
}
}
routing_indicatorsList = OpenAPI_list_create();
cJSON *routing_indicators = cJSON_GetObjectItemCaseSensitive(ausf_infoJSON, "routingIndicators");
OpenAPI_list_t *routing_indicatorsList;
if (routing_indicators) {
cJSON *routing_indicators_local;
if (!cJSON_IsArray(routing_indicators)) {
ogs_error("OpenAPI_ausf_info_parseFromJSON() failed [routing_indicators]");
goto end;
}
routing_indicatorsList = OpenAPI_list_create();
cJSON_ArrayForEach(routing_indicators_local, routing_indicators) {
if (!cJSON_IsString(routing_indicators_local)) {
ogs_error("OpenAPI_ausf_info_parseFromJSON() failed [routing_indicators]");
goto end;
}
OpenAPI_list_add(routing_indicatorsList, ogs_strdup(routing_indicators_local->valuestring));
}
cJSON_ArrayForEach(routing_indicators_local, routing_indicators) {
double *localDouble = NULL;
int *localInt = NULL;
if (!cJSON_IsString(routing_indicators_local)) {
ogs_error("OpenAPI_ausf_info_parseFromJSON() failed [routing_indicators]");
goto end;
}
OpenAPI_list_add(routing_indicatorsList, ogs_strdup(routing_indicators_local->valuestring));
}
}
ausf_info_local_var = OpenAPI_ausf_info_create (
group_id ? ogs_strdup(group_id->valuestring) : NULL,
group_id && !cJSON_IsNull(group_id) ? ogs_strdup(group_id->valuestring) : NULL,
supi_ranges ? supi_rangesList : NULL,
routing_indicators ? routing_indicatorsList : NULL
);
return ausf_info_local_var;
end:
if (supi_rangesList) {
OpenAPI_list_for_each(supi_rangesList, node) {
OpenAPI_supi_range_free(node->data);
}
OpenAPI_list_free(supi_rangesList);
supi_rangesList = NULL;
}
if (routing_indicatorsList) {
OpenAPI_list_for_each(routing_indicatorsList, node) {
ogs_free(node->data);
}
OpenAPI_list_free(routing_indicatorsList);
routing_indicatorsList = NULL;
}
return NULL;
}