forked from acouzens/open5gs
[PCRF] fix the crash in flow->description (#1313)
This commit is contained in:
parent
2ed35f245d
commit
cfd0193bbd
|
@ -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 in' should be changed
|
||||||
* 'permit out' in Gx Diameter */
|
* 'permit out' in Gx Diameter */
|
||||||
len = strlen(rx_flow->description)+2;
|
len = strlen(rx_flow->description)+2;
|
||||||
gx_flow->description = ogs_malloc(len);
|
gx_flow->description = ogs_calloc(1, len);
|
||||||
ogs_assert(gx_flow->description);
|
ogs_assert(gx_flow->description);
|
||||||
strcpy(gx_flow->description, "permit out");
|
strcpy(gx_flow->description, "permit out");
|
||||||
from_str = strstr(&rx_flow->description[strlen("permit in")], "from");
|
from_str = strstr(&rx_flow->description[strlen("permit in")], "from");
|
||||||
|
|
|
@ -455,7 +455,7 @@ done:
|
||||||
BSON_ITER_HOLDS_UTF8(&child8_iter)) {
|
BSON_ITER_HOLDS_UTF8(&child8_iter)) {
|
||||||
utf8 = bson_iter_utf8(
|
utf8 = bson_iter_utf8(
|
||||||
&child8_iter, &length);
|
&child8_iter, &length);
|
||||||
flow->description = ogs_malloc(length+1);
|
flow->description = ogs_calloc(1, length+1);
|
||||||
ogs_assert(flow->description);
|
ogs_assert(flow->description);
|
||||||
ogs_cpystrn((char*)flow->description,
|
ogs_cpystrn((char*)flow->description,
|
||||||
utf8, length+1);
|
utf8, length+1);
|
||||||
|
|
|
@ -363,8 +363,8 @@ ogs_pfcp_pdr_t *ogs_pfcp_handle_create_pdr(ogs_pfcp_sess_t *sess,
|
||||||
if (rule->fd) {
|
if (rule->fd) {
|
||||||
char *flow_description = NULL;
|
char *flow_description = NULL;
|
||||||
|
|
||||||
flow_description = ogs_malloc(
|
flow_description = ogs_calloc(
|
||||||
sdf_filter.flow_description_len+1);
|
1, sdf_filter.flow_description_len+1);
|
||||||
ogs_assert(flow_description);
|
ogs_assert(flow_description);
|
||||||
ogs_cpystrn(flow_description,
|
ogs_cpystrn(flow_description,
|
||||||
sdf_filter.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) {
|
if (rule->fd) {
|
||||||
char *flow_description = NULL;
|
char *flow_description = NULL;
|
||||||
|
|
||||||
flow_description = ogs_malloc(
|
flow_description = ogs_calloc(
|
||||||
sdf_filter.flow_description_len+1);
|
1, sdf_filter.flow_description_len+1);
|
||||||
ogs_assert(flow_description);
|
ogs_assert(flow_description);
|
||||||
ogs_cpystrn(flow_description,
|
ogs_cpystrn(flow_description,
|
||||||
sdf_filter.flow_description,
|
sdf_filter.flow_description,
|
||||||
|
|
|
@ -323,26 +323,27 @@ static int pcrf_rx_aar_cb( struct msg **msg, struct avp *avp,
|
||||||
"permit out", strlen("permit out"))) {
|
"permit out", strlen("permit out"))) {
|
||||||
|
|
||||||
to_ip = strstr(to_str, " ");
|
to_ip = strstr(to_str, " ");
|
||||||
if (to_ip != NULL) {
|
ogs_assert(to_ip);
|
||||||
// Exclude the starting whitespace
|
|
||||||
to_ip += 1;
|
|
||||||
|
|
||||||
to_port = strstr(to_ip, " ");
|
// Exclude the starting whitespace
|
||||||
// Test for no port
|
to_ip += 1;
|
||||||
if (to_port != NULL) {
|
|
||||||
flow->description = ogs_malloc(len
|
to_port = strstr(to_ip, " ");
|
||||||
- strlen(to_str) +
|
// Test for no port
|
||||||
strlen("to any")
|
if (to_port != NULL) {
|
||||||
+ strlen(to_port) + 1);
|
flow->description = ogs_calloc(1,
|
||||||
ogs_assert(flow->description);
|
len - strlen(to_str) +
|
||||||
} else {
|
strlen("to any")
|
||||||
flow->description = ogs_malloc(len
|
+ strlen(to_port) + 1);
|
||||||
- strlen(to_str) +
|
ogs_assert(flow->description);
|
||||||
strlen("to any") + 1);
|
} else {
|
||||||
ogs_assert(flow->description);
|
flow->description = ogs_calloc(1,
|
||||||
}
|
len - strlen(to_str) +
|
||||||
|
strlen("to any") + 1);
|
||||||
|
ogs_assert(flow->description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ogs_assert(flow->description);
|
||||||
strncat(flow->description,
|
strncat(flow->description,
|
||||||
rx_flow,
|
rx_flow,
|
||||||
len - strlen(to_str));
|
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"))) {
|
"permit in", strlen("permit in"))) {
|
||||||
|
|
||||||
from_ip = strstr(from_str, " ");
|
from_ip = strstr(from_str, " ");
|
||||||
if (from_ip != NULL) {
|
ogs_assert(from_ip);
|
||||||
/* Exclude the starting whitespace */
|
|
||||||
from_ip += 1;
|
|
||||||
|
|
||||||
from_port = strstr(from_ip, " ");
|
/* Exclude the starting whitespace */
|
||||||
/* Test for no port +
|
from_ip += 1;
|
||||||
* whether from_port is at "to"
|
|
||||||
* without any from port */
|
from_port = strstr(from_ip, " ");
|
||||||
if (from_port != NULL &&
|
/* Test for no port +
|
||||||
strncmp(from_port, " to", 3)) {
|
* whether from_port is at "to"
|
||||||
flow->description = ogs_malloc(
|
* without any from port */
|
||||||
len - strlen(from_str) +
|
if (from_port != NULL &&
|
||||||
strlen(to_str)
|
strncmp(from_port, " to", 3)) {
|
||||||
+ strlen("from any") + 1
|
flow->description = ogs_calloc(1,
|
||||||
+ (strlen(from_port) -
|
len - strlen(from_str) +
|
||||||
strlen(to_str)));
|
strlen(to_str)
|
||||||
ogs_assert(flow->description);
|
+ strlen("from any") + 1
|
||||||
} else {
|
+ (strlen(from_port) -
|
||||||
flow->description = ogs_malloc(
|
strlen(to_str)));
|
||||||
len - strlen(from_str) +
|
ogs_assert(flow->description);
|
||||||
strlen(to_str)
|
} else {
|
||||||
+ strlen("from any ") + 1);
|
flow->description = ogs_calloc(1,
|
||||||
ogs_assert(flow->description);
|
len - strlen(from_str) +
|
||||||
}
|
strlen(to_str)
|
||||||
|
+ strlen("from any ") + 1);
|
||||||
|
ogs_assert(flow->description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ogs_assert(flow->description);
|
||||||
strncat(flow->description,
|
strncat(flow->description,
|
||||||
rx_flow,
|
rx_flow,
|
||||||
len - strlen(from_str));
|
len - strlen(from_str));
|
||||||
|
|
|
@ -190,15 +190,8 @@ void smf_gsm_state_operational(ogs_fsm_t *s, smf_event_t *e)
|
||||||
smf_ue->supi, sess->psi,
|
smf_ue->supi, sess->psi,
|
||||||
sbi_message->res_status);
|
sbi_message->res_status);
|
||||||
ogs_assert(strerror);
|
ogs_assert(strerror);
|
||||||
|
|
||||||
ogs_error("%s", 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);
|
ogs_free(strerror);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
smf_npcf_smpolicycontrol_handle_delete(
|
smf_npcf_smpolicycontrol_handle_delete(
|
||||||
|
|
Loading…
Reference in New Issue