[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

@ -46,30 +46,47 @@ OpenAPI_amf_event_t *OpenAPI_amf_event_create(
void OpenAPI_amf_event_free(OpenAPI_amf_event_t *amf_event)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == amf_event) {
return;
}
OpenAPI_lnode_t *node;
OpenAPI_amf_event_type_free(amf_event->type);
OpenAPI_list_for_each(amf_event->area_list, node) {
OpenAPI_amf_event_area_free(node->data);
if (amf_event->type) {
OpenAPI_amf_event_type_free(amf_event->type);
amf_event->type = NULL;
}
OpenAPI_list_free(amf_event->area_list);
OpenAPI_list_for_each(amf_event->location_filter_list, node) {
OpenAPI_location_filter_free(node->data);
if (amf_event->area_list) {
OpenAPI_list_for_each(amf_event->area_list, node) {
OpenAPI_amf_event_area_free(node->data);
}
OpenAPI_list_free(amf_event->area_list);
amf_event->area_list = NULL;
}
OpenAPI_list_free(amf_event->location_filter_list);
OpenAPI_list_for_each(amf_event->traffic_descriptor_list, node) {
OpenAPI_traffic_descriptor_free(node->data);
if (amf_event->location_filter_list) {
OpenAPI_list_for_each(amf_event->location_filter_list, node) {
OpenAPI_location_filter_free(node->data);
}
OpenAPI_list_free(amf_event->location_filter_list);
amf_event->location_filter_list = NULL;
}
if (amf_event->traffic_descriptor_list) {
OpenAPI_list_for_each(amf_event->traffic_descriptor_list, node) {
OpenAPI_traffic_descriptor_free(node->data);
}
OpenAPI_list_free(amf_event->traffic_descriptor_list);
amf_event->traffic_descriptor_list = NULL;
}
if (amf_event->reachability_filter) {
OpenAPI_reachability_filter_free(amf_event->reachability_filter);
amf_event->reachability_filter = NULL;
}
OpenAPI_list_free(amf_event->traffic_descriptor_list);
OpenAPI_reachability_filter_free(amf_event->reachability_filter);
ogs_free(amf_event);
}
cJSON *OpenAPI_amf_event_convertToJSON(OpenAPI_amf_event_t *amf_event)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (amf_event == NULL) {
ogs_error("OpenAPI_amf_event_convertToJSON() failed [AmfEvent]");
@ -77,6 +94,10 @@ cJSON *OpenAPI_amf_event_convertToJSON(OpenAPI_amf_event_t *amf_event)
}
item = cJSON_CreateObject();
if (!amf_event->type) {
ogs_error("OpenAPI_amf_event_convertToJSON() failed [type]");
return NULL;
}
cJSON *type_local_JSON = OpenAPI_amf_event_type_convertToJSON(amf_event->type);
if (type_local_JSON == NULL) {
ogs_error("OpenAPI_amf_event_convertToJSON() failed [type]");
@ -101,17 +122,13 @@ cJSON *OpenAPI_amf_event_convertToJSON(OpenAPI_amf_event_t *amf_event)
ogs_error("OpenAPI_amf_event_convertToJSON() failed [area_list]");
goto end;
}
OpenAPI_lnode_t *area_list_node;
if (amf_event->area_list) {
OpenAPI_list_for_each(amf_event->area_list, area_list_node) {
cJSON *itemLocal = OpenAPI_amf_event_area_convertToJSON(area_list_node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_amf_event_convertToJSON() failed [area_list]");
goto end;
}
cJSON_AddItemToArray(area_listList, itemLocal);
OpenAPI_list_for_each(amf_event->area_list, node) {
cJSON *itemLocal = OpenAPI_amf_event_area_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_amf_event_convertToJSON() failed [area_list]");
goto end;
}
cJSON_AddItemToArray(area_listList, itemLocal);
}
}
@ -121,17 +138,13 @@ cJSON *OpenAPI_amf_event_convertToJSON(OpenAPI_amf_event_t *amf_event)
ogs_error("OpenAPI_amf_event_convertToJSON() failed [location_filter_list]");
goto end;
}
OpenAPI_lnode_t *location_filter_list_node;
if (amf_event->location_filter_list) {
OpenAPI_list_for_each(amf_event->location_filter_list, location_filter_list_node) {
cJSON *itemLocal = OpenAPI_location_filter_convertToJSON(location_filter_list_node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_amf_event_convertToJSON() failed [location_filter_list]");
goto end;
}
cJSON_AddItemToArray(location_filter_listList, itemLocal);
OpenAPI_list_for_each(amf_event->location_filter_list, node) {
cJSON *itemLocal = OpenAPI_location_filter_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_amf_event_convertToJSON() failed [location_filter_list]");
goto end;
}
cJSON_AddItemToArray(location_filter_listList, itemLocal);
}
}
@ -148,17 +161,13 @@ cJSON *OpenAPI_amf_event_convertToJSON(OpenAPI_amf_event_t *amf_event)
ogs_error("OpenAPI_amf_event_convertToJSON() failed [traffic_descriptor_list]");
goto end;
}
OpenAPI_lnode_t *traffic_descriptor_list_node;
if (amf_event->traffic_descriptor_list) {
OpenAPI_list_for_each(amf_event->traffic_descriptor_list, traffic_descriptor_list_node) {
cJSON *itemLocal = OpenAPI_traffic_descriptor_convertToJSON(traffic_descriptor_list_node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_amf_event_convertToJSON() failed [traffic_descriptor_list]");
goto end;
}
cJSON_AddItemToArray(traffic_descriptor_listList, itemLocal);
OpenAPI_list_for_each(amf_event->traffic_descriptor_list, node) {
cJSON *itemLocal = OpenAPI_traffic_descriptor_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_amf_event_convertToJSON() failed [traffic_descriptor_list]");
goto end;
}
cJSON_AddItemToArray(traffic_descriptor_listList, itemLocal);
}
}
@ -203,17 +212,30 @@ end:
OpenAPI_amf_event_t *OpenAPI_amf_event_parseFromJSON(cJSON *amf_eventJSON)
{
OpenAPI_amf_event_t *amf_event_local_var = NULL;
cJSON *type = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "type");
OpenAPI_lnode_t *node = NULL;
cJSON *type = NULL;
OpenAPI_amf_event_type_t *type_local_nonprim = NULL;
cJSON *immediate_flag = NULL;
cJSON *area_list = NULL;
OpenAPI_list_t *area_listList = NULL;
cJSON *location_filter_list = NULL;
OpenAPI_list_t *location_filter_listList = NULL;
cJSON *ref_id = NULL;
cJSON *traffic_descriptor_list = NULL;
OpenAPI_list_t *traffic_descriptor_listList = NULL;
cJSON *report_ue_reachable = NULL;
cJSON *reachability_filter = NULL;
OpenAPI_reachability_filter_t *reachability_filter_local_nonprim = NULL;
cJSON *max_reports = NULL;
cJSON *max_response_time = NULL;
type = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "type");
if (!type) {
ogs_error("OpenAPI_amf_event_parseFromJSON() failed [type]");
goto end;
}
OpenAPI_amf_event_type_t *type_local_nonprim = NULL;
type_local_nonprim = OpenAPI_amf_event_type_parseFromJSON(type);
cJSON *immediate_flag = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "immediateFlag");
immediate_flag = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "immediateFlag");
if (immediate_flag) {
if (!cJSON_IsBool(immediate_flag)) {
ogs_error("OpenAPI_amf_event_parseFromJSON() failed [immediate_flag]");
@ -221,66 +243,57 @@ OpenAPI_amf_event_t *OpenAPI_amf_event_parseFromJSON(cJSON *amf_eventJSON)
}
}
cJSON *area_list = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "areaList");
OpenAPI_list_t *area_listList;
area_list = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "areaList");
if (area_list) {
cJSON *area_list_local_nonprimitive;
if (!cJSON_IsArray(area_list)){
ogs_error("OpenAPI_amf_event_parseFromJSON() failed [area_list]");
goto end;
}
area_listList = OpenAPI_list_create();
cJSON_ArrayForEach(area_list_local_nonprimitive, area_list ) {
if (!cJSON_IsObject(area_list_local_nonprimitive)) {
cJSON *area_list_local = NULL;
if (!cJSON_IsArray(area_list)) {
ogs_error("OpenAPI_amf_event_parseFromJSON() failed [area_list]");
goto end;
}
OpenAPI_amf_event_area_t *area_listItem = OpenAPI_amf_event_area_parseFromJSON(area_list_local_nonprimitive);
if (!area_listItem) {
ogs_error("No area_listItem");
OpenAPI_list_free(area_listList);
goto end;
area_listList = OpenAPI_list_create();
cJSON_ArrayForEach(area_list_local, area_list) {
if (!cJSON_IsObject(area_list_local)) {
ogs_error("OpenAPI_amf_event_parseFromJSON() failed [area_list]");
goto end;
}
OpenAPI_amf_event_area_t *area_listItem = OpenAPI_amf_event_area_parseFromJSON(area_list_local);
if (!area_listItem) {
ogs_error("No area_listItem");
OpenAPI_list_free(area_listList);
goto end;
}
OpenAPI_list_add(area_listList, area_listItem);
}
OpenAPI_list_add(area_listList, area_listItem);
}
}
cJSON *location_filter_list = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "locationFilterList");
OpenAPI_list_t *location_filter_listList;
location_filter_list = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "locationFilterList");
if (location_filter_list) {
cJSON *location_filter_list_local_nonprimitive;
if (!cJSON_IsArray(location_filter_list)){
ogs_error("OpenAPI_amf_event_parseFromJSON() failed [location_filter_list]");
goto end;
}
location_filter_listList = OpenAPI_list_create();
cJSON_ArrayForEach(location_filter_list_local_nonprimitive, location_filter_list ) {
if (!cJSON_IsObject(location_filter_list_local_nonprimitive)) {
cJSON *location_filter_list_local = NULL;
if (!cJSON_IsArray(location_filter_list)) {
ogs_error("OpenAPI_amf_event_parseFromJSON() failed [location_filter_list]");
goto end;
}
OpenAPI_location_filter_t *location_filter_listItem = OpenAPI_location_filter_parseFromJSON(location_filter_list_local_nonprimitive);
if (!location_filter_listItem) {
ogs_error("No location_filter_listItem");
OpenAPI_list_free(location_filter_listList);
goto end;
location_filter_listList = OpenAPI_list_create();
cJSON_ArrayForEach(location_filter_list_local, location_filter_list) {
if (!cJSON_IsObject(location_filter_list_local)) {
ogs_error("OpenAPI_amf_event_parseFromJSON() failed [location_filter_list]");
goto end;
}
OpenAPI_location_filter_t *location_filter_listItem = OpenAPI_location_filter_parseFromJSON(location_filter_list_local);
if (!location_filter_listItem) {
ogs_error("No location_filter_listItem");
OpenAPI_list_free(location_filter_listList);
goto end;
}
OpenAPI_list_add(location_filter_listList, location_filter_listItem);
}
OpenAPI_list_add(location_filter_listList, location_filter_listItem);
}
}
cJSON *ref_id = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "refId");
ref_id = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "refId");
if (ref_id) {
if (!cJSON_IsNumber(ref_id)) {
ogs_error("OpenAPI_amf_event_parseFromJSON() failed [ref_id]");
@ -288,37 +301,32 @@ OpenAPI_amf_event_t *OpenAPI_amf_event_parseFromJSON(cJSON *amf_eventJSON)
}
}
cJSON *traffic_descriptor_list = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "trafficDescriptorList");
OpenAPI_list_t *traffic_descriptor_listList;
traffic_descriptor_list = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "trafficDescriptorList");
if (traffic_descriptor_list) {
cJSON *traffic_descriptor_list_local_nonprimitive;
if (!cJSON_IsArray(traffic_descriptor_list)){
ogs_error("OpenAPI_amf_event_parseFromJSON() failed [traffic_descriptor_list]");
goto end;
}
traffic_descriptor_listList = OpenAPI_list_create();
cJSON_ArrayForEach(traffic_descriptor_list_local_nonprimitive, traffic_descriptor_list ) {
if (!cJSON_IsObject(traffic_descriptor_list_local_nonprimitive)) {
cJSON *traffic_descriptor_list_local = NULL;
if (!cJSON_IsArray(traffic_descriptor_list)) {
ogs_error("OpenAPI_amf_event_parseFromJSON() failed [traffic_descriptor_list]");
goto end;
}
OpenAPI_traffic_descriptor_t *traffic_descriptor_listItem = OpenAPI_traffic_descriptor_parseFromJSON(traffic_descriptor_list_local_nonprimitive);
if (!traffic_descriptor_listItem) {
ogs_error("No traffic_descriptor_listItem");
OpenAPI_list_free(traffic_descriptor_listList);
goto end;
traffic_descriptor_listList = OpenAPI_list_create();
cJSON_ArrayForEach(traffic_descriptor_list_local, traffic_descriptor_list) {
if (!cJSON_IsObject(traffic_descriptor_list_local)) {
ogs_error("OpenAPI_amf_event_parseFromJSON() failed [traffic_descriptor_list]");
goto end;
}
OpenAPI_traffic_descriptor_t *traffic_descriptor_listItem = OpenAPI_traffic_descriptor_parseFromJSON(traffic_descriptor_list_local);
if (!traffic_descriptor_listItem) {
ogs_error("No traffic_descriptor_listItem");
OpenAPI_list_free(traffic_descriptor_listList);
goto end;
}
OpenAPI_list_add(traffic_descriptor_listList, traffic_descriptor_listItem);
}
OpenAPI_list_add(traffic_descriptor_listList, traffic_descriptor_listItem);
}
}
cJSON *report_ue_reachable = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "reportUeReachable");
report_ue_reachable = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "reportUeReachable");
if (report_ue_reachable) {
if (!cJSON_IsBool(report_ue_reachable)) {
ogs_error("OpenAPI_amf_event_parseFromJSON() failed [report_ue_reachable]");
@ -326,15 +334,12 @@ OpenAPI_amf_event_t *OpenAPI_amf_event_parseFromJSON(cJSON *amf_eventJSON)
}
}
cJSON *reachability_filter = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "reachabilityFilter");
OpenAPI_reachability_filter_t *reachability_filter_local_nonprim = NULL;
reachability_filter = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "reachabilityFilter");
if (reachability_filter) {
reachability_filter_local_nonprim = OpenAPI_reachability_filter_parseFromJSON(reachability_filter);
}
cJSON *max_reports = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "maxReports");
max_reports = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "maxReports");
if (max_reports) {
if (!cJSON_IsNumber(max_reports)) {
ogs_error("OpenAPI_amf_event_parseFromJSON() failed [max_reports]");
@ -342,8 +347,7 @@ OpenAPI_amf_event_t *OpenAPI_amf_event_parseFromJSON(cJSON *amf_eventJSON)
}
}
cJSON *max_response_time = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "maxResponseTime");
max_response_time = cJSON_GetObjectItemCaseSensitive(amf_eventJSON, "maxResponseTime");
if (max_response_time) {
if (!cJSON_IsNumber(max_response_time)) {
ogs_error("OpenAPI_amf_event_parseFromJSON() failed [max_response_time]");
@ -371,6 +375,35 @@ OpenAPI_amf_event_t *OpenAPI_amf_event_parseFromJSON(cJSON *amf_eventJSON)
return amf_event_local_var;
end:
if (type_local_nonprim) {
OpenAPI_amf_event_type_free(type_local_nonprim);
type_local_nonprim = NULL;
}
if (area_listList) {
OpenAPI_list_for_each(area_listList, node) {
OpenAPI_amf_event_area_free(node->data);
}
OpenAPI_list_free(area_listList);
area_listList = NULL;
}
if (location_filter_listList) {
OpenAPI_list_for_each(location_filter_listList, node) {
OpenAPI_location_filter_free(node->data);
}
OpenAPI_list_free(location_filter_listList);
location_filter_listList = NULL;
}
if (traffic_descriptor_listList) {
OpenAPI_list_for_each(traffic_descriptor_listList, node) {
OpenAPI_traffic_descriptor_free(node->data);
}
OpenAPI_list_free(traffic_descriptor_listList);
traffic_descriptor_listList = NULL;
}
if (reachability_filter_local_nonprim) {
OpenAPI_reachability_filter_free(reachability_filter_local_nonprim);
reachability_filter_local_nonprim = NULL;
}
return NULL;
}