From 3219e52dcf6e771bd03ad4abc3823422edb6e5fe Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Fri, 11 Aug 2017 17:45:46 +0200 Subject: sccp: fixup for osmo_sccp_get_ss7() osmo_sccp_get_ss7() has the risk of a nullpointer dereference, when sccp is NULL. Return NULL when the sccp instance is NULL. Add doxygen comment Change-Id: I84d484e4441fd37443fff8c67e17df8fb15d5b2e --- include/osmocom/sigtran/sccp_sap.h | 2 +- src/sccp_user.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/osmocom/sigtran/sccp_sap.h b/include/osmocom/sigtran/sccp_sap.h index bf1b368..5524bd8 100644 --- a/include/osmocom/sigtran/sccp_sap.h +++ b/include/osmocom/sigtran/sccp_sap.h @@ -246,7 +246,7 @@ void osmo_sccp_vty_init(void); struct osmo_sccp_instance * osmo_sccp_instance_create(struct osmo_ss7_instance *ss7, void *priv); void osmo_sccp_instance_destroy(struct osmo_sccp_instance *inst); -struct osmo_ss7_instance *osmo_sccp_get_ss7(struct osmo_sccp_instance *sccp); +struct osmo_ss7_instance *osmo_sccp_get_ss7(const struct osmo_sccp_instance *sccp); struct osmo_sccp_instance *osmo_sccp_get_sccp(const struct osmo_sccp_user *scu); void osmo_sccp_user_unbind(struct osmo_sccp_user *scu); diff --git a/src/sccp_user.c b/src/sccp_user.c index a4568cf..b0a807d 100644 --- a/src/sccp_user.c +++ b/src/sccp_user.c @@ -598,8 +598,13 @@ out_strings: return NULL; } -struct osmo_ss7_instance *osmo_sccp_get_ss7(struct osmo_sccp_instance *sccp) +/*! \brief get the SS7 instance that is related to the given SCCP instance + * \param[in] sccp SCCP instance + * \returns SS7 instance; NULL if sccp was NULL */ +struct osmo_ss7_instance *osmo_sccp_get_ss7(const struct osmo_sccp_instance *sccp) { + if (!sccp) + return NULL; return sccp->ss7; } -- cgit v1.2.1