mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-04 14:20:09 +00:00
[SBI] Crash occurs when ENUM in the MAP (#2103)
This commit is contained in:
parent
ce668c556c
commit
969c116e77
1097 changed files with 266728 additions and 42047 deletions
|
|
@ -26,27 +26,44 @@ OpenAPI_error_report_t *OpenAPI_error_report_create(
|
|||
|
||||
void OpenAPI_error_report_free(OpenAPI_error_report_t *error_report)
|
||||
{
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (NULL == error_report) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
OpenAPI_problem_details_free(error_report->error);
|
||||
OpenAPI_list_for_each(error_report->rule_reports, node) {
|
||||
OpenAPI_rule_report_free(node->data);
|
||||
if (error_report->error) {
|
||||
OpenAPI_problem_details_free(error_report->error);
|
||||
error_report->error = NULL;
|
||||
}
|
||||
OpenAPI_list_free(error_report->rule_reports);
|
||||
OpenAPI_list_for_each(error_report->sess_rule_reports, node) {
|
||||
OpenAPI_session_rule_report_free(node->data);
|
||||
if (error_report->rule_reports) {
|
||||
OpenAPI_list_for_each(error_report->rule_reports, node) {
|
||||
OpenAPI_rule_report_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(error_report->rule_reports);
|
||||
error_report->rule_reports = NULL;
|
||||
}
|
||||
if (error_report->sess_rule_reports) {
|
||||
OpenAPI_list_for_each(error_report->sess_rule_reports, node) {
|
||||
OpenAPI_session_rule_report_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(error_report->sess_rule_reports);
|
||||
error_report->sess_rule_reports = NULL;
|
||||
}
|
||||
if (error_report->pol_dec_failure_reports) {
|
||||
OpenAPI_list_free(error_report->pol_dec_failure_reports);
|
||||
error_report->pol_dec_failure_reports = NULL;
|
||||
}
|
||||
if (error_report->alt_qos_param_id) {
|
||||
ogs_free(error_report->alt_qos_param_id);
|
||||
error_report->alt_qos_param_id = NULL;
|
||||
}
|
||||
OpenAPI_list_free(error_report->sess_rule_reports);
|
||||
OpenAPI_list_free(error_report->pol_dec_failure_reports);
|
||||
ogs_free(error_report->alt_qos_param_id);
|
||||
ogs_free(error_report);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_error_report_convertToJSON(OpenAPI_error_report_t *error_report)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (error_report == NULL) {
|
||||
ogs_error("OpenAPI_error_report_convertToJSON() failed [ErrorReport]");
|
||||
|
|
@ -73,17 +90,13 @@ cJSON *OpenAPI_error_report_convertToJSON(OpenAPI_error_report_t *error_report)
|
|||
ogs_error("OpenAPI_error_report_convertToJSON() failed [rule_reports]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *rule_reports_node;
|
||||
if (error_report->rule_reports) {
|
||||
OpenAPI_list_for_each(error_report->rule_reports, rule_reports_node) {
|
||||
cJSON *itemLocal = OpenAPI_rule_report_convertToJSON(rule_reports_node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_error_report_convertToJSON() failed [rule_reports]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray(rule_reportsList, itemLocal);
|
||||
OpenAPI_list_for_each(error_report->rule_reports, node) {
|
||||
cJSON *itemLocal = OpenAPI_rule_report_convertToJSON(node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_error_report_convertToJSON() failed [rule_reports]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray(rule_reportsList, itemLocal);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -93,29 +106,24 @@ cJSON *OpenAPI_error_report_convertToJSON(OpenAPI_error_report_t *error_report)
|
|||
ogs_error("OpenAPI_error_report_convertToJSON() failed [sess_rule_reports]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *sess_rule_reports_node;
|
||||
if (error_report->sess_rule_reports) {
|
||||
OpenAPI_list_for_each(error_report->sess_rule_reports, sess_rule_reports_node) {
|
||||
cJSON *itemLocal = OpenAPI_session_rule_report_convertToJSON(sess_rule_reports_node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_error_report_convertToJSON() failed [sess_rule_reports]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray(sess_rule_reportsList, itemLocal);
|
||||
OpenAPI_list_for_each(error_report->sess_rule_reports, node) {
|
||||
cJSON *itemLocal = OpenAPI_session_rule_report_convertToJSON(node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_error_report_convertToJSON() failed [sess_rule_reports]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray(sess_rule_reportsList, itemLocal);
|
||||
}
|
||||
}
|
||||
|
||||
if (error_report->pol_dec_failure_reports) {
|
||||
cJSON *pol_dec_failure_reports = cJSON_AddArrayToObject(item, "polDecFailureReports");
|
||||
if (pol_dec_failure_reports == NULL) {
|
||||
if (error_report->pol_dec_failure_reports != OpenAPI_policy_decision_failure_code_NULL) {
|
||||
cJSON *pol_dec_failure_reportsList = cJSON_AddArrayToObject(item, "polDecFailureReports");
|
||||
if (pol_dec_failure_reportsList == NULL) {
|
||||
ogs_error("OpenAPI_error_report_convertToJSON() failed [pol_dec_failure_reports]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_lnode_t *pol_dec_failure_reports_node;
|
||||
OpenAPI_list_for_each(error_report->pol_dec_failure_reports, pol_dec_failure_reports_node) {
|
||||
if (cJSON_AddStringToObject(pol_dec_failure_reports, "", OpenAPI_policy_decision_failure_code_ToString((intptr_t)pol_dec_failure_reports_node->data)) == NULL) {
|
||||
OpenAPI_list_for_each(error_report->pol_dec_failure_reports, node) {
|
||||
if (cJSON_AddStringToObject(pol_dec_failure_reportsList, "", OpenAPI_policy_decision_failure_code_ToString((intptr_t)node->data)) == NULL) {
|
||||
ogs_error("OpenAPI_error_report_convertToJSON() failed [pol_dec_failure_reports]");
|
||||
goto end;
|
||||
}
|
||||
|
|
@ -136,97 +144,93 @@ end:
|
|||
OpenAPI_error_report_t *OpenAPI_error_report_parseFromJSON(cJSON *error_reportJSON)
|
||||
{
|
||||
OpenAPI_error_report_t *error_report_local_var = NULL;
|
||||
cJSON *error = cJSON_GetObjectItemCaseSensitive(error_reportJSON, "error");
|
||||
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
cJSON *error = NULL;
|
||||
OpenAPI_problem_details_t *error_local_nonprim = NULL;
|
||||
cJSON *rule_reports = NULL;
|
||||
OpenAPI_list_t *rule_reportsList = NULL;
|
||||
cJSON *sess_rule_reports = NULL;
|
||||
OpenAPI_list_t *sess_rule_reportsList = NULL;
|
||||
cJSON *pol_dec_failure_reports = NULL;
|
||||
OpenAPI_list_t *pol_dec_failure_reportsList = NULL;
|
||||
cJSON *alt_qos_param_id = NULL;
|
||||
error = cJSON_GetObjectItemCaseSensitive(error_reportJSON, "error");
|
||||
if (error) {
|
||||
error_local_nonprim = OpenAPI_problem_details_parseFromJSON(error);
|
||||
}
|
||||
|
||||
cJSON *rule_reports = cJSON_GetObjectItemCaseSensitive(error_reportJSON, "ruleReports");
|
||||
|
||||
OpenAPI_list_t *rule_reportsList;
|
||||
rule_reports = cJSON_GetObjectItemCaseSensitive(error_reportJSON, "ruleReports");
|
||||
if (rule_reports) {
|
||||
cJSON *rule_reports_local_nonprimitive;
|
||||
if (!cJSON_IsArray(rule_reports)){
|
||||
ogs_error("OpenAPI_error_report_parseFromJSON() failed [rule_reports]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
rule_reportsList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(rule_reports_local_nonprimitive, rule_reports ) {
|
||||
if (!cJSON_IsObject(rule_reports_local_nonprimitive)) {
|
||||
cJSON *rule_reports_local = NULL;
|
||||
if (!cJSON_IsArray(rule_reports)) {
|
||||
ogs_error("OpenAPI_error_report_parseFromJSON() failed [rule_reports]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_rule_report_t *rule_reportsItem = OpenAPI_rule_report_parseFromJSON(rule_reports_local_nonprimitive);
|
||||
|
||||
if (!rule_reportsItem) {
|
||||
ogs_error("No rule_reportsItem");
|
||||
OpenAPI_list_free(rule_reportsList);
|
||||
goto end;
|
||||
rule_reportsList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(rule_reports_local, rule_reports) {
|
||||
if (!cJSON_IsObject(rule_reports_local)) {
|
||||
ogs_error("OpenAPI_error_report_parseFromJSON() failed [rule_reports]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_rule_report_t *rule_reportsItem = OpenAPI_rule_report_parseFromJSON(rule_reports_local);
|
||||
if (!rule_reportsItem) {
|
||||
ogs_error("No rule_reportsItem");
|
||||
OpenAPI_list_free(rule_reportsList);
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(rule_reportsList, rule_reportsItem);
|
||||
}
|
||||
|
||||
OpenAPI_list_add(rule_reportsList, rule_reportsItem);
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *sess_rule_reports = cJSON_GetObjectItemCaseSensitive(error_reportJSON, "sessRuleReports");
|
||||
|
||||
OpenAPI_list_t *sess_rule_reportsList;
|
||||
sess_rule_reports = cJSON_GetObjectItemCaseSensitive(error_reportJSON, "sessRuleReports");
|
||||
if (sess_rule_reports) {
|
||||
cJSON *sess_rule_reports_local_nonprimitive;
|
||||
if (!cJSON_IsArray(sess_rule_reports)){
|
||||
ogs_error("OpenAPI_error_report_parseFromJSON() failed [sess_rule_reports]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
sess_rule_reportsList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(sess_rule_reports_local_nonprimitive, sess_rule_reports ) {
|
||||
if (!cJSON_IsObject(sess_rule_reports_local_nonprimitive)) {
|
||||
cJSON *sess_rule_reports_local = NULL;
|
||||
if (!cJSON_IsArray(sess_rule_reports)) {
|
||||
ogs_error("OpenAPI_error_report_parseFromJSON() failed [sess_rule_reports]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_session_rule_report_t *sess_rule_reportsItem = OpenAPI_session_rule_report_parseFromJSON(sess_rule_reports_local_nonprimitive);
|
||||
|
||||
if (!sess_rule_reportsItem) {
|
||||
ogs_error("No sess_rule_reportsItem");
|
||||
OpenAPI_list_free(sess_rule_reportsList);
|
||||
goto end;
|
||||
sess_rule_reportsList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(sess_rule_reports_local, sess_rule_reports) {
|
||||
if (!cJSON_IsObject(sess_rule_reports_local)) {
|
||||
ogs_error("OpenAPI_error_report_parseFromJSON() failed [sess_rule_reports]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_session_rule_report_t *sess_rule_reportsItem = OpenAPI_session_rule_report_parseFromJSON(sess_rule_reports_local);
|
||||
if (!sess_rule_reportsItem) {
|
||||
ogs_error("No sess_rule_reportsItem");
|
||||
OpenAPI_list_free(sess_rule_reportsList);
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(sess_rule_reportsList, sess_rule_reportsItem);
|
||||
}
|
||||
|
||||
OpenAPI_list_add(sess_rule_reportsList, sess_rule_reportsItem);
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *pol_dec_failure_reports = cJSON_GetObjectItemCaseSensitive(error_reportJSON, "polDecFailureReports");
|
||||
|
||||
OpenAPI_list_t *pol_dec_failure_reportsList;
|
||||
pol_dec_failure_reports = cJSON_GetObjectItemCaseSensitive(error_reportJSON, "polDecFailureReports");
|
||||
if (pol_dec_failure_reports) {
|
||||
cJSON *pol_dec_failure_reports_local_nonprimitive;
|
||||
if (!cJSON_IsArray(pol_dec_failure_reports)) {
|
||||
ogs_error("OpenAPI_error_report_parseFromJSON() failed [pol_dec_failure_reports]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
pol_dec_failure_reportsList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(pol_dec_failure_reports_local_nonprimitive, pol_dec_failure_reports ) {
|
||||
if (!cJSON_IsString(pol_dec_failure_reports_local_nonprimitive)){
|
||||
cJSON *pol_dec_failure_reports_local = NULL;
|
||||
if (!cJSON_IsArray(pol_dec_failure_reports)) {
|
||||
ogs_error("OpenAPI_error_report_parseFromJSON() failed [pol_dec_failure_reports]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_list_add(pol_dec_failure_reportsList, (void *)OpenAPI_policy_decision_failure_code_FromString(pol_dec_failure_reports_local_nonprimitive->valuestring));
|
||||
}
|
||||
pol_dec_failure_reportsList = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach(pol_dec_failure_reports_local, pol_dec_failure_reports) {
|
||||
if (!cJSON_IsString(pol_dec_failure_reports_local)) {
|
||||
ogs_error("OpenAPI_error_report_parseFromJSON() failed [pol_dec_failure_reports]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(pol_dec_failure_reportsList, (void *)OpenAPI_policy_decision_failure_code_FromString(pol_dec_failure_reports_local->valuestring));
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *alt_qos_param_id = cJSON_GetObjectItemCaseSensitive(error_reportJSON, "altQosParamId");
|
||||
|
||||
alt_qos_param_id = cJSON_GetObjectItemCaseSensitive(error_reportJSON, "altQosParamId");
|
||||
if (alt_qos_param_id) {
|
||||
if (!cJSON_IsString(alt_qos_param_id)) {
|
||||
if (!cJSON_IsString(alt_qos_param_id) && !cJSON_IsNull(alt_qos_param_id)) {
|
||||
ogs_error("OpenAPI_error_report_parseFromJSON() failed [alt_qos_param_id]");
|
||||
goto end;
|
||||
}
|
||||
|
|
@ -237,11 +241,33 @@ OpenAPI_error_report_t *OpenAPI_error_report_parseFromJSON(cJSON *error_reportJS
|
|||
rule_reports ? rule_reportsList : NULL,
|
||||
sess_rule_reports ? sess_rule_reportsList : NULL,
|
||||
pol_dec_failure_reports ? pol_dec_failure_reportsList : NULL,
|
||||
alt_qos_param_id ? ogs_strdup(alt_qos_param_id->valuestring) : NULL
|
||||
alt_qos_param_id && !cJSON_IsNull(alt_qos_param_id) ? ogs_strdup(alt_qos_param_id->valuestring) : NULL
|
||||
);
|
||||
|
||||
return error_report_local_var;
|
||||
end:
|
||||
if (error_local_nonprim) {
|
||||
OpenAPI_problem_details_free(error_local_nonprim);
|
||||
error_local_nonprim = NULL;
|
||||
}
|
||||
if (rule_reportsList) {
|
||||
OpenAPI_list_for_each(rule_reportsList, node) {
|
||||
OpenAPI_rule_report_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(rule_reportsList);
|
||||
rule_reportsList = NULL;
|
||||
}
|
||||
if (sess_rule_reportsList) {
|
||||
OpenAPI_list_for_each(sess_rule_reportsList, node) {
|
||||
OpenAPI_session_rule_report_free(node->data);
|
||||
}
|
||||
OpenAPI_list_free(sess_rule_reportsList);
|
||||
sess_rule_reportsList = NULL;
|
||||
}
|
||||
if (pol_dec_failure_reportsList) {
|
||||
OpenAPI_list_free(pol_dec_failure_reportsList);
|
||||
pol_dec_failure_reportsList = NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue