[MERGED] libosmo-sccp[master]: sccp: fixup for osmo_sccp_get_ss7()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sun Aug 13 22:47:54 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: sccp: fixup for osmo_sccp_get_ss7()
......................................................................


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
---
M include/osmocom/sigtran/sccp_sap.h
M src/sccp_user.c
2 files changed, 7 insertions(+), 2 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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 @@
 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 @@
 	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;
 }
 

-- 
To view, visit https://gerrit.osmocom.org/3485
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I84d484e4441fd37443fff8c67e17df8fb15d5b2e
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list