diff --git a/lib/sbi/context.c b/lib/sbi/context.c index e7a440200..3e6f04d57 100644 --- a/lib/sbi/context.c +++ b/lib/sbi/context.c @@ -1861,15 +1861,21 @@ ogs_sbi_subscription_spec_t *ogs_sbi_subscription_spec_add( { ogs_sbi_subscription_spec_t *subscription_spec = NULL; - ogs_assert(nf_type); + /* Issue #2630 : The format of subscrCond is invalid. Must be 'oneOf'. */ + ogs_assert(!nf_type || !service_name); ogs_pool_alloc(&subscription_spec_pool, &subscription_spec); ogs_assert(subscription_spec); memset(subscription_spec, 0, sizeof(ogs_sbi_subscription_spec_t)); - subscription_spec->subscr_cond.nf_type = nf_type; - if (service_name) + if (nf_type) + subscription_spec->subscr_cond.nf_type = nf_type; + else if (service_name) subscription_spec->subscr_cond.service_name = ogs_strdup(service_name); + else { + ogs_fatal("SubscrCond must be 'oneOf'."); + ogs_assert_if_reached(); + } ogs_list_add(&ogs_sbi_self()->subscription_spec_list, subscription_spec); diff --git a/lib/sbi/nnrf-build.c b/lib/sbi/nnrf-build.c index 196e9fd46..9d2fc5af8 100644 --- a/lib/sbi/nnrf-build.c +++ b/lib/sbi/nnrf-build.c @@ -1501,6 +1501,10 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_status_subscribe( ogs_assert(subscription_data); ogs_assert(subscription_data->req_nf_type); + /* Issue #2630 : The format of subscrCond is invalid. Must be 'oneOf'. */ + ogs_assert(!subscription_data->subscr_cond.nf_type || + !subscription_data->subscr_cond.service_name); + memset(&message, 0, sizeof(message)); message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST; message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; @@ -1549,10 +1553,12 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_status_subscribe( if (subscription_data->subscr_cond.nf_type) { SubscrCond.nf_type = subscription_data->subscr_cond.nf_type; SubscriptionData->subscr_cond = &SubscrCond; - } - if (subscription_data->subscr_cond.service_name) { + } else if (subscription_data->subscr_cond.service_name) { SubscrCond.service_name = subscription_data->subscr_cond.service_name; SubscriptionData->subscr_cond = &SubscrCond; + } else { + ogs_fatal("SubscrCond must be 'oneOf'."); + ogs_assert_if_reached(); } message.SubscriptionData = SubscriptionData; diff --git a/lib/sbi/nnrf-path.c b/lib/sbi/nnrf-path.c index 4775d2aa2..957f633e2 100644 --- a/lib/sbi/nnrf-path.c +++ b/lib/sbi/nnrf-path.c @@ -94,16 +94,25 @@ bool ogs_nnrf_nfm_send_nf_status_subscribe( ogs_sbi_request_t *request = NULL; ogs_sbi_subscription_data_t *subscription_data = NULL; + /* Issue #2630 : The format of subscrCond is invalid. Must be 'oneOf'. */ + ogs_assert(!subscr_cond_nf_type || !subscr_cond_service_name); + subscription_data = ogs_sbi_subscription_data_add(); ogs_assert(subscription_data); subscription_data->req_nf_type = req_nf_type; if (req_nf_instance_id) subscription_data->req_nf_instance_id = ogs_strdup(req_nf_instance_id); - subscription_data->subscr_cond.nf_type = subscr_cond_nf_type; - if (subscr_cond_service_name) + + if (subscr_cond_nf_type) + subscription_data->subscr_cond.nf_type = subscr_cond_nf_type; + else if (subscr_cond_service_name) subscription_data->subscr_cond.service_name = ogs_strdup(subscr_cond_service_name); + else { + ogs_fatal("SubscrCond must be 'oneOf'."); + ogs_assert_if_reached(); + } request = ogs_nnrf_nfm_build_status_subscribe(subscription_data); if (!request) { diff --git a/src/amf/sbi-path.c b/src/amf/sbi-path.c index 4c31012f4..fd0aa62b5 100644 --- a/src/amf/sbi-path.c +++ b/src/amf/sbi-path.c @@ -54,17 +54,17 @@ int amf_sbi_open(void) /* Setup Subscription-Data */ ogs_sbi_subscription_spec_add( - OpenAPI_nf_type_AUSF, OGS_SBI_SERVICE_NAME_NAUSF_AUTH); + OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NAUSF_AUTH); ogs_sbi_subscription_spec_add( - OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_UECM); + OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NUDM_UECM); ogs_sbi_subscription_spec_add( - OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_SDM); + OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NUDM_SDM); ogs_sbi_subscription_spec_add( - OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL); + OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL); ogs_sbi_subscription_spec_add( - OpenAPI_nf_type_SMF, OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION); + OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION); ogs_sbi_subscription_spec_add( - OpenAPI_nf_type_NSSF, OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION); + OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION); if (ogs_sbi_server_start_all(ogs_sbi_server_handler) != OGS_OK) return OGS_ERROR; diff --git a/src/ausf/sbi-path.c b/src/ausf/sbi-path.c index a5d994bfe..6feb27a8a 100644 --- a/src/ausf/sbi-path.c +++ b/src/ausf/sbi-path.c @@ -51,7 +51,7 @@ int ausf_sbi_open(void) /* Setup Subscription-Data */ ogs_sbi_subscription_spec_add( - OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_UEAU); + OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NUDM_UEAU); if (ogs_sbi_server_start_all(ogs_sbi_server_handler) != OGS_OK) return OGS_ERROR; diff --git a/src/nrf/nnrf-handler.c b/src/nrf/nnrf-handler.c index 5b50ee5a7..e601ce586 100644 --- a/src/nrf/nnrf-handler.c +++ b/src/nrf/nnrf-handler.c @@ -268,7 +268,7 @@ bool nrf_nnrf_handle_nf_status_subscribe( if (!subscription_data->req_nf_instance_id) { ogs_error("ogs_strdup() failed"); ogs_sbi_subscription_data_remove(subscription_data); - return NULL; + return false; } } @@ -281,7 +281,7 @@ bool nrf_nnrf_handle_nf_status_subscribe( if (!SubscriptionData->subscription_id) { ogs_error("ogs_strdup() failed"); ogs_sbi_subscription_data_remove(subscription_data); - return NULL; + return false; } if (SubscriptionData->requester_features) { @@ -302,15 +302,29 @@ bool nrf_nnrf_handle_nf_status_subscribe( if (!SubscriptionData->nrf_supported_features) { ogs_error("ogs_strdup() failed"); ogs_sbi_subscription_data_remove(subscription_data); - return NULL; + return false; } SubscrCond = SubscriptionData->subscr_cond; if (SubscrCond) { - subscription_data->subscr_cond.nf_type = SubscrCond->nf_type; - if (SubscrCond->service_name) + + /* Issue #2630 : The format of subscrCond is invalid. Must be 'oneOf'. */ + if (SubscrCond->nf_type && SubscrCond->service_name) { + ogs_error("SubscrCond must be 'oneOf'"); + ogs_sbi_subscription_data_remove(subscription_data); + return false; + } + + if (SubscrCond->nf_type) + subscription_data->subscr_cond.nf_type = SubscrCond->nf_type; + else if (SubscrCond->service_name) subscription_data->subscr_cond.service_name = ogs_strdup(SubscrCond->service_name); + else { + ogs_error("No SubscrCond"); + ogs_sbi_subscription_data_remove(subscription_data); + return false; + } } subscription_data->notification_uri = diff --git a/src/nrf/sbi-path.c b/src/nrf/sbi-path.c index e2641d624..257c52ccc 100644 --- a/src/nrf/sbi-path.c +++ b/src/nrf/sbi-path.c @@ -121,16 +121,14 @@ bool nrf_nnrf_nfm_send_nf_status_notify_all( strcmp(subscription_data->req_nf_instance_id, nf_instance->id) == 0) continue; - if (subscription_data->subscr_cond.nf_type && - subscription_data->subscr_cond.nf_type != nf_instance->nf_type) - continue; + /* Issue #2630 : The format of subscrCond is invalid. Must be 'oneOf'. */ + if (subscription_data->subscr_cond.nf_type) { - if (subscription_data->req_nf_type && - ogs_sbi_nf_instance_is_allowed_nf_type( - nf_instance, subscription_data->req_nf_type) == false) - continue; + if (subscription_data->subscr_cond.nf_type != nf_instance->nf_type) + continue; + + } else if (subscription_data->subscr_cond.service_name) { - if (subscription_data->subscr_cond.service_name) { ogs_sbi_nf_service_t *nf_service = ogs_sbi_nf_service_find_by_name(nf_instance, subscription_data->subscr_cond.service_name); @@ -142,6 +140,11 @@ bool nrf_nnrf_nfm_send_nf_status_notify_all( continue; } + if (subscription_data->req_nf_type && + ogs_sbi_nf_instance_is_allowed_nf_type( + nf_instance, subscription_data->req_nf_type) == false) + continue; + rc = nrf_nnrf_nfm_send_nf_status_notify( subscription_data, event, nf_instance); if (rc == false) { diff --git a/src/pcf/sbi-path.c b/src/pcf/sbi-path.c index 18663d79f..e4a632c3f 100644 --- a/src/pcf/sbi-path.c +++ b/src/pcf/sbi-path.c @@ -98,9 +98,9 @@ int pcf_sbi_open(void) /* Setup Subscription-Data */ ogs_sbi_subscription_spec_add( - OpenAPI_nf_type_BSF, OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT); + OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT); ogs_sbi_subscription_spec_add( - OpenAPI_nf_type_UDR, OGS_SBI_SERVICE_NAME_NUDR_DR); + OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NUDR_DR); if (ogs_sbi_server_start_all(ogs_sbi_server_handler) != OGS_OK) return OGS_ERROR; diff --git a/src/smf/sbi-path.c b/src/smf/sbi-path.c index 4fc1b4b8f..4f3f1afc8 100644 --- a/src/smf/sbi-path.c +++ b/src/smf/sbi-path.c @@ -62,13 +62,13 @@ int smf_sbi_open(void) /* Setup Subscription-Data */ ogs_sbi_subscription_spec_add( - OpenAPI_nf_type_AMF, OGS_SBI_SERVICE_NAME_NAMF_COMM); + OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NAMF_COMM); ogs_sbi_subscription_spec_add( - OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL); + OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL); ogs_sbi_subscription_spec_add( - OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_SDM); + OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NUDM_SDM); ogs_sbi_subscription_spec_add( - OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_UECM); + OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NUDM_UECM); if (ogs_sbi_server_start_all(ogs_sbi_server_handler) != OGS_OK) return OGS_ERROR; diff --git a/tests/af/sbi-path.c b/tests/af/sbi-path.c index e29e20f7f..7615f5059 100644 --- a/tests/af/sbi-path.c +++ b/tests/af/sbi-path.c @@ -38,7 +38,7 @@ int af_sbi_open(void) /* Setup Subscription-Data */ ogs_sbi_subscription_spec_add( - OpenAPI_nf_type_BSF, OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT); + OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT); if (ogs_sbi_server_start_all(ogs_sbi_server_handler) != OGS_OK) return OGS_ERROR;