nat: Fix a crash when a BSC disconnects while a rejected IMSI
When we reject the IMSI we do not have the msc_con set on the
SCCP connection, but we do have a remote_ref. So the nat_send_rlsd
will end up with a crash due the msc_con being zero. Fix the
crash by only sending a released to the MSC when the connection
is not local.
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c
index dde9196..23b8111 100644
--- a/openbsc/src/nat/bsc_nat.c
+++ b/openbsc/src/nat/bsc_nat.c
@@ -329,6 +329,7 @@
queue_for_msc(con->msc_con, rlsd);
}
con->con_local = 1;
+ con->msc_con = NULL;
/* 2. release the BSC side */
if (con->con_type == NAT_CON_TYPE_LU) {
@@ -676,7 +677,7 @@
if (ctr)
rate_ctr_inc(ctr);
- if (sccp_patch->has_remote_ref)
+ if (sccp_patch->has_remote_ref && !sccp_patch->con_local)
nat_send_rlsd(sccp_patch);
sccp_connection_destroy(sccp_patch);
}