[SBI] crash when enum is unknown (#2622)

j
The crash is caused by ogs_assert(data) in listEntry_create(void *data).
Reason for the failing assertion is that in

OpenAPI_subscription_data_t *OpenAPI_subscription_data_parseFromJSON(
        cJSON *subscription_dataJSON)

in line 501 of file subscription_data.c the event string is transformed
into an integer/enum value, which in case of an unknown event is 0.

Steps to reproduce:

1. Deploy NRF
2. Run curl --http2-prior-knowledge --header "Content-Type: application/json" --data '{"nfStatusNotificationUri": "test@example.com", "reqNotifEvents": ["unknown"], "subscriptionId": "12345"}' "http://<NRF_IP>:<NRF_PORT>/nnrf-nfm/v1/subscriptions"
This commit is contained in:
Sukchan Lee 2023-09-24 09:54:53 +09:00
parent 317d9bf846
commit 0abfb204ea
72 changed files with 854 additions and 122 deletions

View file

@ -235,11 +235,17 @@ OpenAPI_error_report_t *OpenAPI_error_report_parseFromJSON(cJSON *error_reportJS
pol_dec_failure_reportsList = OpenAPI_list_create();
cJSON_ArrayForEach(pol_dec_failure_reports_local, pol_dec_failure_reports) {
OpenAPI_policy_decision_failure_code_e localEnum = OpenAPI_policy_decision_failure_code_NULL;
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));
localEnum = OpenAPI_policy_decision_failure_code_FromString(pol_dec_failure_reports_local->valuestring);
if (!localEnum) {
ogs_error("OpenAPI_policy_decision_failure_code_FromString(pol_dec_failure_reports_local->valuestring) failed");
goto end;
}
OpenAPI_list_add(pol_dec_failure_reportsList, (void *)localEnum);
}
}