[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

@ -26,17 +26,22 @@ OpenAPI_deregistration_data_t *OpenAPI_deregistration_data_create(
void OpenAPI_deregistration_data_free(OpenAPI_deregistration_data_t *deregistration_data)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == deregistration_data) {
return;
}
OpenAPI_lnode_t *node;
ogs_free(deregistration_data->new_smf_instance_id);
if (deregistration_data->new_smf_instance_id) {
ogs_free(deregistration_data->new_smf_instance_id);
deregistration_data->new_smf_instance_id = NULL;
}
ogs_free(deregistration_data);
}
cJSON *OpenAPI_deregistration_data_convertToJSON(OpenAPI_deregistration_data_t *deregistration_data)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (deregistration_data == NULL) {
ogs_error("OpenAPI_deregistration_data_convertToJSON() failed [DeregistrationData]");
@ -44,12 +49,16 @@ cJSON *OpenAPI_deregistration_data_convertToJSON(OpenAPI_deregistration_data_t *
}
item = cJSON_CreateObject();
if (deregistration_data->dereg_reason == OpenAPI_deregistration_reason_NULL) {
ogs_error("OpenAPI_deregistration_data_convertToJSON() failed [dereg_reason]");
return NULL;
}
if (cJSON_AddStringToObject(item, "deregReason", OpenAPI_deregistration_reason_ToString(deregistration_data->dereg_reason)) == NULL) {
ogs_error("OpenAPI_deregistration_data_convertToJSON() failed [dereg_reason]");
goto end;
}
if (deregistration_data->access_type) {
if (deregistration_data->access_type != OpenAPI_access_type_NULL) {
if (cJSON_AddStringToObject(item, "accessType", OpenAPI_access_type_ToString(deregistration_data->access_type)) == NULL) {
ogs_error("OpenAPI_deregistration_data_convertToJSON() failed [access_type]");
goto end;
@ -77,22 +86,25 @@ end:
OpenAPI_deregistration_data_t *OpenAPI_deregistration_data_parseFromJSON(cJSON *deregistration_dataJSON)
{
OpenAPI_deregistration_data_t *deregistration_data_local_var = NULL;
cJSON *dereg_reason = cJSON_GetObjectItemCaseSensitive(deregistration_dataJSON, "deregReason");
OpenAPI_lnode_t *node = NULL;
cJSON *dereg_reason = NULL;
OpenAPI_deregistration_reason_e dereg_reasonVariable = 0;
cJSON *access_type = NULL;
OpenAPI_access_type_e access_typeVariable = 0;
cJSON *pdu_session_id = NULL;
cJSON *new_smf_instance_id = NULL;
dereg_reason = cJSON_GetObjectItemCaseSensitive(deregistration_dataJSON, "deregReason");
if (!dereg_reason) {
ogs_error("OpenAPI_deregistration_data_parseFromJSON() failed [dereg_reason]");
goto end;
}
OpenAPI_deregistration_reason_e dereg_reasonVariable;
if (!cJSON_IsString(dereg_reason)) {
ogs_error("OpenAPI_deregistration_data_parseFromJSON() failed [dereg_reason]");
goto end;
}
dereg_reasonVariable = OpenAPI_deregistration_reason_FromString(dereg_reason->valuestring);
cJSON *access_type = cJSON_GetObjectItemCaseSensitive(deregistration_dataJSON, "accessType");
OpenAPI_access_type_e access_typeVariable;
access_type = cJSON_GetObjectItemCaseSensitive(deregistration_dataJSON, "accessType");
if (access_type) {
if (!cJSON_IsString(access_type)) {
ogs_error("OpenAPI_deregistration_data_parseFromJSON() failed [access_type]");
@ -101,8 +113,7 @@ OpenAPI_deregistration_data_t *OpenAPI_deregistration_data_parseFromJSON(cJSON *
access_typeVariable = OpenAPI_access_type_FromString(access_type->valuestring);
}
cJSON *pdu_session_id = cJSON_GetObjectItemCaseSensitive(deregistration_dataJSON, "pduSessionId");
pdu_session_id = cJSON_GetObjectItemCaseSensitive(deregistration_dataJSON, "pduSessionId");
if (pdu_session_id) {
if (!cJSON_IsNumber(pdu_session_id)) {
ogs_error("OpenAPI_deregistration_data_parseFromJSON() failed [pdu_session_id]");
@ -110,10 +121,9 @@ OpenAPI_deregistration_data_t *OpenAPI_deregistration_data_parseFromJSON(cJSON *
}
}
cJSON *new_smf_instance_id = cJSON_GetObjectItemCaseSensitive(deregistration_dataJSON, "newSmfInstanceId");
new_smf_instance_id = cJSON_GetObjectItemCaseSensitive(deregistration_dataJSON, "newSmfInstanceId");
if (new_smf_instance_id) {
if (!cJSON_IsString(new_smf_instance_id)) {
if (!cJSON_IsString(new_smf_instance_id) && !cJSON_IsNull(new_smf_instance_id)) {
ogs_error("OpenAPI_deregistration_data_parseFromJSON() failed [new_smf_instance_id]");
goto end;
}
@ -124,7 +134,7 @@ OpenAPI_deregistration_data_t *OpenAPI_deregistration_data_parseFromJSON(cJSON *
access_type ? access_typeVariable : 0,
pdu_session_id ? true : false,
pdu_session_id ? pdu_session_id->valuedouble : 0,
new_smf_instance_id ? ogs_strdup(new_smf_instance_id->valuestring) : NULL
new_smf_instance_id && !cJSON_IsNull(new_smf_instance_id) ? ogs_strdup(new_smf_instance_id->valuestring) : NULL
);
return deregistration_data_local_var;