Skip to content

Commit

Permalink
[SBI] Fixed crash if no BW Unit(Xbps) (#2000)
Browse files Browse the repository at this point in the history
  • Loading branch information
acetcom committed Jan 24, 2023
1 parent 1d57db6 commit 2f525f0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
5 changes: 5 additions & 0 deletions lib/sbi/conv.c
Expand Up @@ -290,6 +290,11 @@ uint64_t ogs_sbi_bitrate_from_string(char *str)
unit = strrchr(str, ' ');
bitrate = atoll(str);

if (!unit) {
ogs_error("No Unit [%s]", str);
return bitrate;
}

SWITCH(unit+1)
CASE("Kbps")
return bitrate * 1024;
Expand Down
22 changes: 18 additions & 4 deletions src/pcf/npcf-handler.c
Expand Up @@ -591,6 +591,13 @@ bool pcf_npcf_policyauthorization_handle_create(pcf_sess_t *sess,
uint8_t qos_index = 0;
ogs_media_component_t *media_component = &ims_data.media_component[i];

if (media_component->media_type == OpenAPI_media_type_NULL) {
strerror = ogs_msprintf("[%s:%d] Media-Type is Required",
pcf_ue->supi, sess->psi);
status = OGS_SBI_HTTP_STATUS_BAD_REQUEST;
goto cleanup;
}

switch(media_component->media_type) {
case OpenAPI_media_type_AUDIO:
qos_index = OGS_QOS_INDEX_1;
Expand All @@ -602,9 +609,9 @@ bool pcf_npcf_policyauthorization_handle_create(pcf_sess_t *sess,
qos_index = OGS_QOS_INDEX_5;
break;
default:
strerror = ogs_msprintf("[%s:%d] Not implemented : [Media-Type:%d]",
strerror = ogs_msprintf("[%s:%d] Unknown Media-Type [%d]",
pcf_ue->supi, sess->psi, media_component->media_type);
status = OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR;
status = OGS_SBI_HTTP_STATUS_BAD_REQUEST;
goto cleanup;
}

Expand Down Expand Up @@ -1004,6 +1011,13 @@ bool pcf_npcf_policyauthorization_handle_update(
uint8_t qos_index = 0;
ogs_media_component_t *media_component = &ims_data.media_component[i];

if (media_component->media_type == OpenAPI_media_type_NULL) {
strerror = ogs_msprintf("[%s:%d] Media-Type is Required",
pcf_ue->supi, sess->psi);
status = OGS_SBI_HTTP_STATUS_BAD_REQUEST;
goto cleanup;
}

switch(media_component->media_type) {
case OpenAPI_media_type_AUDIO:
qos_index = OGS_QOS_INDEX_1;
Expand All @@ -1015,9 +1029,9 @@ bool pcf_npcf_policyauthorization_handle_update(
qos_index = OGS_QOS_INDEX_5;
break;
default:
strerror = ogs_msprintf("[%s:%d] Not implemented : [Media-Type:%d]",
strerror = ogs_msprintf("[%s:%d] Unknown Media-Type [%d]",
pcf_ue->supi, sess->psi, media_component->media_type);
status = OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR;
status = OGS_SBI_HTTP_STATUS_BAD_REQUEST;
goto cleanup;
}

Expand Down

0 comments on commit 2f525f0

Please sign in to comment.