[DIAM] Fix the crash when terminating Diameter

When exiting a diameter interface, the session state data could be NULL.
So we added code to check the session state data
to prevent SIGSEGV occurring.
This commit is contained in:
Sukchan Lee 2024-07-20 10:16:28 +09:00
parent a9a60135f9
commit 8d2d037314
11 changed files with 52 additions and 3 deletions

View file

@ -49,6 +49,11 @@ struct sess_state {
static void state_cleanup(struct sess_state *sess_data, os0_t sid, void *opaque)
{
if (!sess_data) {
ogs_error("No session state");
return;
}
ogs_free(sess_data);
}

View file

@ -45,6 +45,11 @@ static void mme_s6a_pua_cb(void *data, struct msg **msg);
static void state_cleanup(struct sess_state *sess_data, os0_t sid, void *opaque)
{
if (!sess_data) {
ogs_error("No session state");
return;
}
ogs_free(sess_data);
}

View file

@ -180,7 +180,10 @@ static struct rx_sess_state *find_rx_state(struct sess_state *gx, os0_t sid)
static void state_cleanup(struct sess_state *sess_data, os0_t sid, void *opaque)
{
ogs_assert(sess_data);
if (!sess_data) {
ogs_error("No session state");
return;
}
if (sess_data->peer_host)
ogs_free(sess_data->peer_host);

View file

@ -73,7 +73,10 @@ static __inline__ struct sess_state *new_state(os0_t sid)
static void state_cleanup(struct sess_state *sess_data, os0_t sid, void *opaque)
{
ogs_assert(sess_data);
if (!sess_data) {
ogs_error("No session state");
return;
}
if (sess_data->rx_sid)
ogs_free((char *)sess_data->rx_sid);

View file

@ -76,6 +76,11 @@ static __inline__ struct sess_state *new_state(os0_t sid)
static void state_cleanup(struct sess_state *sess_data, os0_t sid, void *opaque)
{
if (!sess_data) {
ogs_error("No session state");
return;
}
if (sess_data->gx_sid)
ogs_free(sess_data->gx_sid);

View file

@ -80,6 +80,11 @@ static __inline__ struct sess_state *new_state(os0_t sid)
static void state_cleanup(struct sess_state *sess_data, os0_t sid, void *opaque)
{
if (!sess_data) {
ogs_error("No session state");
return;
}
if (sess_data->gy_sid)
ogs_free(sess_data->gy_sid);

View file

@ -64,6 +64,11 @@ static __inline__ struct sess_state *new_state(os0_t sid)
static void state_cleanup(struct sess_state *sess_data, os0_t sid, void *opaque)
{
if (!sess_data) {
ogs_error("No session state");
return;
}
if (sess_data->s6b_sid)
ogs_free(sess_data->s6b_sid);

View file

@ -66,7 +66,10 @@ static __inline__ struct sess_state *new_state(os0_t sid)
static void state_cleanup(struct sess_state *sess_data, os0_t sid, void *opaque)
{
ogs_assert(sess_data);
if (!sess_data) {
ogs_error("No session state");
return;
}
if (sess_data->sid)
ogs_free(sess_data->sid);

View file

@ -48,6 +48,11 @@ static void test_swx_saa_cb(void *data, struct msg **msg);
static void state_cleanup(struct sess_state *sess_data, os0_t sid, void *opaque)
{
if (!sess_data) {
ogs_error("No session state");
return;
}
if (sess_data->user_name)
ogs_free(sess_data->user_name);

View file

@ -52,6 +52,11 @@ static void test_cx_lia_cb(void *data, struct msg **msg);
static void state_cleanup(struct sess_state *sess_data, os0_t sid, void *opaque)
{
if (!sess_data) {
ogs_error("No session state");
return;
}
if (sess_data->user_name)
ogs_free(sess_data->user_name);
if (sess_data->public_identity)

View file

@ -51,6 +51,11 @@ static __inline__ struct sess_state *new_state(os0_t sid)
static void state_cleanup(struct sess_state *sess_data, os0_t sid, void *opaque)
{
if (!sess_data) {
ogs_error("No session state");
return;
}
if (sess_data->sid)
ogs_free(sess_data->sid);