[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

@ -12,7 +12,11 @@ OpenAPI_problem_details_1_t *OpenAPI_problem_details_1_create(
char *detail,
char *instance,
char *cause,
OpenAPI_list_t *invalid_params
OpenAPI_list_t *invalid_params,
char *supported_features,
OpenAPI_access_token_err_t *access_token_error,
OpenAPI_access_token_req_t *access_token_request,
char *nrf_id
)
{
OpenAPI_problem_details_1_t *problem_details_1_local_var = ogs_malloc(sizeof(OpenAPI_problem_details_1_t));
@ -26,31 +30,71 @@ OpenAPI_problem_details_1_t *OpenAPI_problem_details_1_create(
problem_details_1_local_var->instance = instance;
problem_details_1_local_var->cause = cause;
problem_details_1_local_var->invalid_params = invalid_params;
problem_details_1_local_var->supported_features = supported_features;
problem_details_1_local_var->access_token_error = access_token_error;
problem_details_1_local_var->access_token_request = access_token_request;
problem_details_1_local_var->nrf_id = nrf_id;
return problem_details_1_local_var;
}
void OpenAPI_problem_details_1_free(OpenAPI_problem_details_1_t *problem_details_1)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == problem_details_1) {
return;
}
OpenAPI_lnode_t *node;
ogs_free(problem_details_1->type);
ogs_free(problem_details_1->title);
ogs_free(problem_details_1->detail);
ogs_free(problem_details_1->instance);
ogs_free(problem_details_1->cause);
OpenAPI_list_for_each(problem_details_1->invalid_params, node) {
OpenAPI_invalid_param_1_free(node->data);
if (problem_details_1->type) {
ogs_free(problem_details_1->type);
problem_details_1->type = NULL;
}
if (problem_details_1->title) {
ogs_free(problem_details_1->title);
problem_details_1->title = NULL;
}
if (problem_details_1->detail) {
ogs_free(problem_details_1->detail);
problem_details_1->detail = NULL;
}
if (problem_details_1->instance) {
ogs_free(problem_details_1->instance);
problem_details_1->instance = NULL;
}
if (problem_details_1->cause) {
ogs_free(problem_details_1->cause);
problem_details_1->cause = NULL;
}
if (problem_details_1->invalid_params) {
OpenAPI_list_for_each(problem_details_1->invalid_params, node) {
OpenAPI_invalid_param_free(node->data);
}
OpenAPI_list_free(problem_details_1->invalid_params);
problem_details_1->invalid_params = NULL;
}
if (problem_details_1->supported_features) {
ogs_free(problem_details_1->supported_features);
problem_details_1->supported_features = NULL;
}
if (problem_details_1->access_token_error) {
OpenAPI_access_token_err_free(problem_details_1->access_token_error);
problem_details_1->access_token_error = NULL;
}
if (problem_details_1->access_token_request) {
OpenAPI_access_token_req_free(problem_details_1->access_token_request);
problem_details_1->access_token_request = NULL;
}
if (problem_details_1->nrf_id) {
ogs_free(problem_details_1->nrf_id);
problem_details_1->nrf_id = NULL;
}
OpenAPI_list_free(problem_details_1->invalid_params);
ogs_free(problem_details_1);
}
cJSON *OpenAPI_problem_details_1_convertToJSON(OpenAPI_problem_details_1_t *problem_details_1)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (problem_details_1 == NULL) {
ogs_error("OpenAPI_problem_details_1_convertToJSON() failed [ProblemDetails_1]");
@ -106,17 +150,53 @@ cJSON *OpenAPI_problem_details_1_convertToJSON(OpenAPI_problem_details_1_t *prob
ogs_error("OpenAPI_problem_details_1_convertToJSON() failed [invalid_params]");
goto end;
}
OpenAPI_lnode_t *invalid_params_node;
if (problem_details_1->invalid_params) {
OpenAPI_list_for_each(problem_details_1->invalid_params, invalid_params_node) {
cJSON *itemLocal = OpenAPI_invalid_param_1_convertToJSON(invalid_params_node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_problem_details_1_convertToJSON() failed [invalid_params]");
goto end;
}
cJSON_AddItemToArray(invalid_paramsList, itemLocal);
OpenAPI_list_for_each(problem_details_1->invalid_params, node) {
cJSON *itemLocal = OpenAPI_invalid_param_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_problem_details_1_convertToJSON() failed [invalid_params]");
goto end;
}
cJSON_AddItemToArray(invalid_paramsList, itemLocal);
}
}
if (problem_details_1->supported_features) {
if (cJSON_AddStringToObject(item, "supportedFeatures", problem_details_1->supported_features) == NULL) {
ogs_error("OpenAPI_problem_details_1_convertToJSON() failed [supported_features]");
goto end;
}
}
if (problem_details_1->access_token_error) {
cJSON *access_token_error_local_JSON = OpenAPI_access_token_err_convertToJSON(problem_details_1->access_token_error);
if (access_token_error_local_JSON == NULL) {
ogs_error("OpenAPI_problem_details_1_convertToJSON() failed [access_token_error]");
goto end;
}
cJSON_AddItemToObject(item, "accessTokenError", access_token_error_local_JSON);
if (item->child == NULL) {
ogs_error("OpenAPI_problem_details_1_convertToJSON() failed [access_token_error]");
goto end;
}
}
if (problem_details_1->access_token_request) {
cJSON *access_token_request_local_JSON = OpenAPI_access_token_req_convertToJSON(problem_details_1->access_token_request);
if (access_token_request_local_JSON == NULL) {
ogs_error("OpenAPI_problem_details_1_convertToJSON() failed [access_token_request]");
goto end;
}
cJSON_AddItemToObject(item, "accessTokenRequest", access_token_request_local_JSON);
if (item->child == NULL) {
ogs_error("OpenAPI_problem_details_1_convertToJSON() failed [access_token_request]");
goto end;
}
}
if (problem_details_1->nrf_id) {
if (cJSON_AddStringToObject(item, "nrfId", problem_details_1->nrf_id) == NULL) {
ogs_error("OpenAPI_problem_details_1_convertToJSON() failed [nrf_id]");
goto end;
}
}
@ -127,26 +207,38 @@ end:
OpenAPI_problem_details_1_t *OpenAPI_problem_details_1_parseFromJSON(cJSON *problem_details_1JSON)
{
OpenAPI_problem_details_1_t *problem_details_1_local_var = NULL;
cJSON *type = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "type");
OpenAPI_lnode_t *node = NULL;
cJSON *type = NULL;
cJSON *title = NULL;
cJSON *status = NULL;
cJSON *detail = NULL;
cJSON *instance = NULL;
cJSON *cause = NULL;
cJSON *invalid_params = NULL;
OpenAPI_list_t *invalid_paramsList = NULL;
cJSON *supported_features = NULL;
cJSON *access_token_error = NULL;
OpenAPI_access_token_err_t *access_token_error_local_nonprim = NULL;
cJSON *access_token_request = NULL;
OpenAPI_access_token_req_t *access_token_request_local_nonprim = NULL;
cJSON *nrf_id = NULL;
type = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "type");
if (type) {
if (!cJSON_IsString(type)) {
if (!cJSON_IsString(type) && !cJSON_IsNull(type)) {
ogs_error("OpenAPI_problem_details_1_parseFromJSON() failed [type]");
goto end;
}
}
cJSON *title = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "title");
title = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "title");
if (title) {
if (!cJSON_IsString(title)) {
if (!cJSON_IsString(title) && !cJSON_IsNull(title)) {
ogs_error("OpenAPI_problem_details_1_parseFromJSON() failed [title]");
goto end;
}
}
cJSON *status = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "status");
status = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "status");
if (status) {
if (!cJSON_IsNumber(status)) {
ogs_error("OpenAPI_problem_details_1_parseFromJSON() failed [status]");
@ -154,75 +246,113 @@ OpenAPI_problem_details_1_t *OpenAPI_problem_details_1_parseFromJSON(cJSON *prob
}
}
cJSON *detail = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "detail");
detail = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "detail");
if (detail) {
if (!cJSON_IsString(detail)) {
if (!cJSON_IsString(detail) && !cJSON_IsNull(detail)) {
ogs_error("OpenAPI_problem_details_1_parseFromJSON() failed [detail]");
goto end;
}
}
cJSON *instance = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "instance");
instance = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "instance");
if (instance) {
if (!cJSON_IsString(instance)) {
if (!cJSON_IsString(instance) && !cJSON_IsNull(instance)) {
ogs_error("OpenAPI_problem_details_1_parseFromJSON() failed [instance]");
goto end;
}
}
cJSON *cause = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "cause");
cause = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "cause");
if (cause) {
if (!cJSON_IsString(cause)) {
if (!cJSON_IsString(cause) && !cJSON_IsNull(cause)) {
ogs_error("OpenAPI_problem_details_1_parseFromJSON() failed [cause]");
goto end;
}
}
cJSON *invalid_params = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "invalidParams");
OpenAPI_list_t *invalid_paramsList;
invalid_params = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "invalidParams");
if (invalid_params) {
cJSON *invalid_params_local_nonprimitive;
if (!cJSON_IsArray(invalid_params)){
ogs_error("OpenAPI_problem_details_1_parseFromJSON() failed [invalid_params]");
goto end;
}
invalid_paramsList = OpenAPI_list_create();
cJSON_ArrayForEach(invalid_params_local_nonprimitive, invalid_params ) {
if (!cJSON_IsObject(invalid_params_local_nonprimitive)) {
cJSON *invalid_params_local = NULL;
if (!cJSON_IsArray(invalid_params)) {
ogs_error("OpenAPI_problem_details_1_parseFromJSON() failed [invalid_params]");
goto end;
}
OpenAPI_invalid_param_1_t *invalid_paramsItem = OpenAPI_invalid_param_1_parseFromJSON(invalid_params_local_nonprimitive);
if (!invalid_paramsItem) {
ogs_error("No invalid_paramsItem");
OpenAPI_list_free(invalid_paramsList);
goto end;
invalid_paramsList = OpenAPI_list_create();
cJSON_ArrayForEach(invalid_params_local, invalid_params) {
if (!cJSON_IsObject(invalid_params_local)) {
ogs_error("OpenAPI_problem_details_1_parseFromJSON() failed [invalid_params]");
goto end;
}
OpenAPI_invalid_param_t *invalid_paramsItem = OpenAPI_invalid_param_parseFromJSON(invalid_params_local);
if (!invalid_paramsItem) {
ogs_error("No invalid_paramsItem");
OpenAPI_list_free(invalid_paramsList);
goto end;
}
OpenAPI_list_add(invalid_paramsList, invalid_paramsItem);
}
}
OpenAPI_list_add(invalid_paramsList, invalid_paramsItem);
supported_features = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "supportedFeatures");
if (supported_features) {
if (!cJSON_IsString(supported_features) && !cJSON_IsNull(supported_features)) {
ogs_error("OpenAPI_problem_details_1_parseFromJSON() failed [supported_features]");
goto end;
}
}
access_token_error = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "accessTokenError");
if (access_token_error) {
access_token_error_local_nonprim = OpenAPI_access_token_err_parseFromJSON(access_token_error);
}
access_token_request = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "accessTokenRequest");
if (access_token_request) {
access_token_request_local_nonprim = OpenAPI_access_token_req_parseFromJSON(access_token_request);
}
nrf_id = cJSON_GetObjectItemCaseSensitive(problem_details_1JSON, "nrfId");
if (nrf_id) {
if (!cJSON_IsString(nrf_id) && !cJSON_IsNull(nrf_id)) {
ogs_error("OpenAPI_problem_details_1_parseFromJSON() failed [nrf_id]");
goto end;
}
}
problem_details_1_local_var = OpenAPI_problem_details_1_create (
type ? ogs_strdup(type->valuestring) : NULL,
title ? ogs_strdup(title->valuestring) : NULL,
type && !cJSON_IsNull(type) ? ogs_strdup(type->valuestring) : NULL,
title && !cJSON_IsNull(title) ? ogs_strdup(title->valuestring) : NULL,
status ? true : false,
status ? status->valuedouble : 0,
detail ? ogs_strdup(detail->valuestring) : NULL,
instance ? ogs_strdup(instance->valuestring) : NULL,
cause ? ogs_strdup(cause->valuestring) : NULL,
invalid_params ? invalid_paramsList : NULL
detail && !cJSON_IsNull(detail) ? ogs_strdup(detail->valuestring) : NULL,
instance && !cJSON_IsNull(instance) ? ogs_strdup(instance->valuestring) : NULL,
cause && !cJSON_IsNull(cause) ? ogs_strdup(cause->valuestring) : NULL,
invalid_params ? invalid_paramsList : NULL,
supported_features && !cJSON_IsNull(supported_features) ? ogs_strdup(supported_features->valuestring) : NULL,
access_token_error ? access_token_error_local_nonprim : NULL,
access_token_request ? access_token_request_local_nonprim : NULL,
nrf_id && !cJSON_IsNull(nrf_id) ? ogs_strdup(nrf_id->valuestring) : NULL
);
return problem_details_1_local_var;
end:
if (invalid_paramsList) {
OpenAPI_list_for_each(invalid_paramsList, node) {
OpenAPI_invalid_param_free(node->data);
}
OpenAPI_list_free(invalid_paramsList);
invalid_paramsList = NULL;
}
if (access_token_error_local_nonprim) {
OpenAPI_access_token_err_free(access_token_error_local_nonprim);
access_token_error_local_nonprim = NULL;
}
if (access_token_request_local_nonprim) {
OpenAPI_access_token_req_free(access_token_request_local_nonprim);
access_token_request_local_nonprim = NULL;
}
return NULL;
}