[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

@ -6,10 +6,10 @@
OpenAPI_qos_flow_setup_item_t *OpenAPI_qos_flow_setup_item_create(
int qfi,
char qos_rules,
char *qos_rules,
bool is_ebi,
int ebi,
char qos_flow_description,
char *qos_flow_description,
OpenAPI_qos_flow_profile_t *qos_flow_profile,
OpenAPI_qos_flow_access_type_e associated_an_type
)
@ -30,17 +30,30 @@ OpenAPI_qos_flow_setup_item_t *OpenAPI_qos_flow_setup_item_create(
void OpenAPI_qos_flow_setup_item_free(OpenAPI_qos_flow_setup_item_t *qos_flow_setup_item)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == qos_flow_setup_item) {
return;
}
OpenAPI_lnode_t *node;
OpenAPI_qos_flow_profile_free(qos_flow_setup_item->qos_flow_profile);
if (qos_flow_setup_item->qos_rules) {
ogs_free(qos_flow_setup_item->qos_rules);
qos_flow_setup_item->qos_rules = NULL;
}
if (qos_flow_setup_item->qos_flow_description) {
ogs_free(qos_flow_setup_item->qos_flow_description);
qos_flow_setup_item->qos_flow_description = NULL;
}
if (qos_flow_setup_item->qos_flow_profile) {
OpenAPI_qos_flow_profile_free(qos_flow_setup_item->qos_flow_profile);
qos_flow_setup_item->qos_flow_profile = NULL;
}
ogs_free(qos_flow_setup_item);
}
cJSON *OpenAPI_qos_flow_setup_item_convertToJSON(OpenAPI_qos_flow_setup_item_t *qos_flow_setup_item)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (qos_flow_setup_item == NULL) {
ogs_error("OpenAPI_qos_flow_setup_item_convertToJSON() failed [QosFlowSetupItem]");
@ -53,7 +66,11 @@ cJSON *OpenAPI_qos_flow_setup_item_convertToJSON(OpenAPI_qos_flow_setup_item_t *
goto end;
}
if (cJSON_AddNumberToObject(item, "qosRules", qos_flow_setup_item->qos_rules) == NULL) {
if (!qos_flow_setup_item->qos_rules) {
ogs_error("OpenAPI_qos_flow_setup_item_convertToJSON() failed [qos_rules]");
return NULL;
}
if (cJSON_AddStringToObject(item, "qosRules", qos_flow_setup_item->qos_rules) == NULL) {
ogs_error("OpenAPI_qos_flow_setup_item_convertToJSON() failed [qos_rules]");
goto end;
}
@ -66,7 +83,7 @@ cJSON *OpenAPI_qos_flow_setup_item_convertToJSON(OpenAPI_qos_flow_setup_item_t *
}
if (qos_flow_setup_item->qos_flow_description) {
if (cJSON_AddNumberToObject(item, "qosFlowDescription", qos_flow_setup_item->qos_flow_description) == NULL) {
if (cJSON_AddStringToObject(item, "qosFlowDescription", qos_flow_setup_item->qos_flow_description) == NULL) {
ogs_error("OpenAPI_qos_flow_setup_item_convertToJSON() failed [qos_flow_description]");
goto end;
}
@ -85,7 +102,7 @@ cJSON *OpenAPI_qos_flow_setup_item_convertToJSON(OpenAPI_qos_flow_setup_item_t *
}
}
if (qos_flow_setup_item->associated_an_type) {
if (qos_flow_setup_item->associated_an_type != OpenAPI_qos_flow_access_type_NULL) {
if (cJSON_AddStringToObject(item, "associatedAnType", OpenAPI_qos_flow_access_type_ToString(qos_flow_setup_item->associated_an_type)) == NULL) {
ogs_error("OpenAPI_qos_flow_setup_item_convertToJSON() failed [associated_an_type]");
goto end;
@ -99,30 +116,36 @@ end:
OpenAPI_qos_flow_setup_item_t *OpenAPI_qos_flow_setup_item_parseFromJSON(cJSON *qos_flow_setup_itemJSON)
{
OpenAPI_qos_flow_setup_item_t *qos_flow_setup_item_local_var = NULL;
cJSON *qfi = cJSON_GetObjectItemCaseSensitive(qos_flow_setup_itemJSON, "qfi");
OpenAPI_lnode_t *node = NULL;
cJSON *qfi = NULL;
cJSON *qos_rules = NULL;
cJSON *ebi = NULL;
cJSON *qos_flow_description = NULL;
cJSON *qos_flow_profile = NULL;
OpenAPI_qos_flow_profile_t *qos_flow_profile_local_nonprim = NULL;
cJSON *associated_an_type = NULL;
OpenAPI_qos_flow_access_type_e associated_an_typeVariable = 0;
qfi = cJSON_GetObjectItemCaseSensitive(qos_flow_setup_itemJSON, "qfi");
if (!qfi) {
ogs_error("OpenAPI_qos_flow_setup_item_parseFromJSON() failed [qfi]");
goto end;
}
if (!cJSON_IsNumber(qfi)) {
ogs_error("OpenAPI_qos_flow_setup_item_parseFromJSON() failed [qfi]");
goto end;
}
cJSON *qos_rules = cJSON_GetObjectItemCaseSensitive(qos_flow_setup_itemJSON, "qosRules");
qos_rules = cJSON_GetObjectItemCaseSensitive(qos_flow_setup_itemJSON, "qosRules");
if (!qos_rules) {
ogs_error("OpenAPI_qos_flow_setup_item_parseFromJSON() failed [qos_rules]");
goto end;
}
if (!cJSON_IsNumber(qos_rules)) {
if (!cJSON_IsString(qos_rules)) {
ogs_error("OpenAPI_qos_flow_setup_item_parseFromJSON() failed [qos_rules]");
goto end;
}
cJSON *ebi = cJSON_GetObjectItemCaseSensitive(qos_flow_setup_itemJSON, "ebi");
ebi = cJSON_GetObjectItemCaseSensitive(qos_flow_setup_itemJSON, "ebi");
if (ebi) {
if (!cJSON_IsNumber(ebi)) {
ogs_error("OpenAPI_qos_flow_setup_item_parseFromJSON() failed [ebi]");
@ -130,25 +153,20 @@ OpenAPI_qos_flow_setup_item_t *OpenAPI_qos_flow_setup_item_parseFromJSON(cJSON *
}
}
cJSON *qos_flow_description = cJSON_GetObjectItemCaseSensitive(qos_flow_setup_itemJSON, "qosFlowDescription");
qos_flow_description = cJSON_GetObjectItemCaseSensitive(qos_flow_setup_itemJSON, "qosFlowDescription");
if (qos_flow_description) {
if (!cJSON_IsNumber(qos_flow_description)) {
if (!cJSON_IsString(qos_flow_description) && !cJSON_IsNull(qos_flow_description)) {
ogs_error("OpenAPI_qos_flow_setup_item_parseFromJSON() failed [qos_flow_description]");
goto end;
}
}
cJSON *qos_flow_profile = cJSON_GetObjectItemCaseSensitive(qos_flow_setup_itemJSON, "qosFlowProfile");
OpenAPI_qos_flow_profile_t *qos_flow_profile_local_nonprim = NULL;
qos_flow_profile = cJSON_GetObjectItemCaseSensitive(qos_flow_setup_itemJSON, "qosFlowProfile");
if (qos_flow_profile) {
qos_flow_profile_local_nonprim = OpenAPI_qos_flow_profile_parseFromJSON(qos_flow_profile);
}
cJSON *associated_an_type = cJSON_GetObjectItemCaseSensitive(qos_flow_setup_itemJSON, "associatedAnType");
OpenAPI_qos_flow_access_type_e associated_an_typeVariable;
associated_an_type = cJSON_GetObjectItemCaseSensitive(qos_flow_setup_itemJSON, "associatedAnType");
if (associated_an_type) {
if (!cJSON_IsString(associated_an_type)) {
ogs_error("OpenAPI_qos_flow_setup_item_parseFromJSON() failed [associated_an_type]");
@ -160,16 +178,20 @@ OpenAPI_qos_flow_setup_item_t *OpenAPI_qos_flow_setup_item_parseFromJSON(cJSON *
qos_flow_setup_item_local_var = OpenAPI_qos_flow_setup_item_create (
qfi->valuedouble,
qos_rules->valueint,
ogs_strdup(qos_rules->valuestring),
ebi ? true : false,
ebi ? ebi->valuedouble : 0,
qos_flow_description ? qos_flow_description->valueint : 0,
qos_flow_description && !cJSON_IsNull(qos_flow_description) ? ogs_strdup(qos_flow_description->valuestring) : NULL,
qos_flow_profile ? qos_flow_profile_local_nonprim : NULL,
associated_an_type ? associated_an_typeVariable : 0
);
return qos_flow_setup_item_local_var;
end:
if (qos_flow_profile_local_nonprim) {
OpenAPI_qos_flow_profile_free(qos_flow_profile_local_nonprim);
qos_flow_profile_local_nonprim = NULL;
}
return NULL;
}