[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

@ -494,11 +494,17 @@ OpenAPI_subscription_data_t *OpenAPI_subscription_data_parseFromJSON(cJSON *subs
req_notif_eventsList = OpenAPI_list_create();
cJSON_ArrayForEach(req_notif_events_local, req_notif_events) {
OpenAPI_notification_event_type_e localEnum = OpenAPI_notification_event_type_NULL;
if (!cJSON_IsString(req_notif_events_local)) {
ogs_error("OpenAPI_subscription_data_parseFromJSON() failed [req_notif_events]");
goto end;
}
OpenAPI_list_add(req_notif_eventsList, (void *)OpenAPI_notification_event_type_FromString(req_notif_events_local->valuestring));
localEnum = OpenAPI_notification_event_type_FromString(req_notif_events_local->valuestring);
if (!localEnum) {
ogs_error("OpenAPI_notification_event_type_FromString(req_notif_events_local->valuestring) failed");
goto end;
}
OpenAPI_list_add(req_notif_eventsList, (void *)localEnum);
}
}