diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2017-06-20 22:49:34 +0200 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2017-07-05 13:04:16 +0200 |
commit | cb246316505c8cf9913fb66596362fee90b10476 (patch) | |
tree | aeb8de0f6a7c2b8f49fbab1c9fdb54ea3b079682 | |
parent | 0f88c110093935305143987638e46dc6db304a3e (diff) |
sccp_sap_up(): guard against NULL pointers
Change-Id: Icd64b92b00461cace5c476c8bcf69eec3fdbbdd3
-rw-r--r-- | src/hnbgw_cn.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/hnbgw_cn.c b/src/hnbgw_cn.c index 2fd9d71..8124ce5 100644 --- a/src/hnbgw_cn.c +++ b/src/hnbgw_cn.c @@ -327,12 +327,27 @@ static int handle_cn_disc_ind(struct hnbgw_cnlink *cnlink, static int sccp_sap_up(struct osmo_prim_hdr *oph, void *ctx) { struct osmo_sccp_user *scu = ctx; - struct hnbgw_cnlink *cnlink = osmo_sccp_user_get_priv(scu); + struct hnbgw_cnlink *cnlink; struct osmo_scu_prim *prim = (struct osmo_scu_prim *) oph; int rc; LOGP(DMAIN, LOGL_DEBUG, "sccp_sap_up(%s)\n", osmo_scu_prim_name(oph)); + if (!scu) { + LOGP(DMAIN, LOGL_ERROR, + "sccp_sap_up(): NULL osmo_sccp_user, cannot send prim (sap %u prim %u op %d)\n", + oph->sap, oph->primitive, oph->operation); + return -1; + } + + cnlink = osmo_sccp_user_get_priv(scu); + if (!cnlink) { + LOGP(DMAIN, LOGL_ERROR, + "sccp_sap_up(): NULL hnbgw_cnlink, cannot send prim (sap %u prim %u op %d)\n", + oph->sap, oph->primitive, oph->operation); + return -1; + } + switch (OSMO_PRIM_HDR(oph)) { case OSMO_PRIM(OSMO_SCU_PRIM_N_UNITDATA, PRIM_OP_INDICATION): rc = handle_cn_unitdata(cnlink, &prim->u.unitdata, oph); |