[PCRF] fix the crash in flow->description (#1313)

This commit is contained in:
Sukchan Lee 2022-01-12 10:15:36 +09:00
parent 2ed35f245d
commit cfd0193bbd
5 changed files with 48 additions and 53 deletions

View File

@ -748,7 +748,7 @@ static int flow_rx_to_gx(ogs_flow_t *rx_flow, ogs_flow_t *gx_flow)
/* 'permit in' should be changed
* 'permit out' in Gx Diameter */
len = strlen(rx_flow->description)+2;
gx_flow->description = ogs_malloc(len);
gx_flow->description = ogs_calloc(1, len);
ogs_assert(gx_flow->description);
strcpy(gx_flow->description, "permit out");
from_str = strstr(&rx_flow->description[strlen("permit in")], "from");

View File

@ -455,7 +455,7 @@ done:
BSON_ITER_HOLDS_UTF8(&child8_iter)) {
utf8 = bson_iter_utf8(
&child8_iter, &length);
flow->description = ogs_malloc(length+1);
flow->description = ogs_calloc(1, length+1);
ogs_assert(flow->description);
ogs_cpystrn((char*)flow->description,
utf8, length+1);

View File

@ -363,8 +363,8 @@ ogs_pfcp_pdr_t *ogs_pfcp_handle_create_pdr(ogs_pfcp_sess_t *sess,
if (rule->fd) {
char *flow_description = NULL;
flow_description = ogs_malloc(
sdf_filter.flow_description_len+1);
flow_description = ogs_calloc(
1, sdf_filter.flow_description_len+1);
ogs_assert(flow_description);
ogs_cpystrn(flow_description,
sdf_filter.flow_description,
@ -616,8 +616,8 @@ ogs_pfcp_pdr_t *ogs_pfcp_handle_update_pdr(ogs_pfcp_sess_t *sess,
if (rule->fd) {
char *flow_description = NULL;
flow_description = ogs_malloc(
sdf_filter.flow_description_len+1);
flow_description = ogs_calloc(
1, sdf_filter.flow_description_len+1);
ogs_assert(flow_description);
ogs_cpystrn(flow_description,
sdf_filter.flow_description,

View File

@ -323,26 +323,27 @@ static int pcrf_rx_aar_cb( struct msg **msg, struct avp *avp,
"permit out", strlen("permit out"))) {
to_ip = strstr(to_str, " ");
if (to_ip != NULL) {
// Exclude the starting whitespace
to_ip += 1;
ogs_assert(to_ip);
to_port = strstr(to_ip, " ");
// Test for no port
if (to_port != NULL) {
flow->description = ogs_malloc(len
- strlen(to_str) +
strlen("to any")
+ strlen(to_port) + 1);
ogs_assert(flow->description);
} else {
flow->description = ogs_malloc(len
- strlen(to_str) +
strlen("to any") + 1);
ogs_assert(flow->description);
}
// Exclude the starting whitespace
to_ip += 1;
to_port = strstr(to_ip, " ");
// Test for no port
if (to_port != NULL) {
flow->description = ogs_calloc(1,
len - strlen(to_str) +
strlen("to any")
+ strlen(to_port) + 1);
ogs_assert(flow->description);
} else {
flow->description = ogs_calloc(1,
len - strlen(to_str) +
strlen("to any") + 1);
ogs_assert(flow->description);
}
ogs_assert(flow->description);
strncat(flow->description,
rx_flow,
len - strlen(to_str));
@ -355,32 +356,33 @@ static int pcrf_rx_aar_cb( struct msg **msg, struct avp *avp,
"permit in", strlen("permit in"))) {
from_ip = strstr(from_str, " ");
if (from_ip != NULL) {
/* Exclude the starting whitespace */
from_ip += 1;
ogs_assert(from_ip);
from_port = strstr(from_ip, " ");
/* Test for no port +
* whether from_port is at "to"
* without any from port */
if (from_port != NULL &&
strncmp(from_port, " to", 3)) {
flow->description = ogs_malloc(
len - strlen(from_str) +
strlen(to_str)
+ strlen("from any") + 1
+ (strlen(from_port) -
strlen(to_str)));
ogs_assert(flow->description);
} else {
flow->description = ogs_malloc(
len - strlen(from_str) +
strlen(to_str)
+ strlen("from any ") + 1);
ogs_assert(flow->description);
}
/* Exclude the starting whitespace */
from_ip += 1;
from_port = strstr(from_ip, " ");
/* Test for no port +
* whether from_port is at "to"
* without any from port */
if (from_port != NULL &&
strncmp(from_port, " to", 3)) {
flow->description = ogs_calloc(1,
len - strlen(from_str) +
strlen(to_str)
+ strlen("from any") + 1
+ (strlen(from_port) -
strlen(to_str)));
ogs_assert(flow->description);
} else {
flow->description = ogs_calloc(1,
len - strlen(from_str) +
strlen(to_str)
+ strlen("from any ") + 1);
ogs_assert(flow->description);
}
ogs_assert(flow->description);
strncat(flow->description,
rx_flow,
len - strlen(from_str));

View File

@ -190,15 +190,8 @@ void smf_gsm_state_operational(ogs_fsm_t *s, smf_event_t *e)
smf_ue->supi, sess->psi,
sbi_message->res_status);
ogs_assert(strerror);
ogs_error("%s", strerror);
if (stream)
ogs_assert(true ==
ogs_sbi_server_send_error(stream,
sbi_message->res_status,
sbi_message, strerror, NULL));
ogs_free(strerror);
break;
}
smf_npcf_smpolicycontrol_handle_delete(