Change in osmo-msc[master]: libmsc: Make sure to not dereference a NULL trans

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/.

tnt gerrit-no-reply at lists.osmocom.org
Fri May 10 09:56:20 UTC 2019


tnt has uploaded this change for review. ( https://gerrit.osmocom.org/13963


Change subject: libmsc: Make sure to not dereference a NULL trans
......................................................................

libmsc: Make sure to not dereference a NULL trans

All those were identified by gcc. At this point in the code, trans is
NULL and so you can't call LOG_TRANS because it will try to access the
log_subsys field.

Instead call LOG_TRANS_CAT with manually specified category where
applicable (or other logging primitive depending on what the surrounding
code does)

Change-Id: Ia14bd28e1db570c487ad8e90e29a69208e2226f2
Signed-off-by: Sylvain Munaut <tnt at 246tNt.com>
---
M src/libmsc/gsm_04_08_cc.c
M src/libmsc/gsm_04_11.c
M src/libmsc/gsm_09_11.c
M src/libmsc/transaction.c
4 files changed, 12 insertions(+), 12 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/63/13963/1

diff --git a/src/libmsc/gsm_04_08_cc.c b/src/libmsc/gsm_04_08_cc.c
index 2869bba..7d09e0e 100644
--- a/src/libmsc/gsm_04_08_cc.c
+++ b/src/libmsc/gsm_04_08_cc.c
@@ -1888,7 +1888,7 @@
 		trans = trans_alloc(net, vsub, TRANS_CC,
 				    TRANS_ID_UNASSIGNED, data->callref);
 		if (!trans) {
-			LOG_TRANS(trans, LOGL_ERROR, "No memory for trans.\n");
+			LOG_TRANS_CAT(trans, DCC, LOGL_ERROR, "No memory for trans.\n");
 			vlr_subscr_put(vsub, __func__);
 			/* Ressource unavailable */
 			mncc_release_ind(net, NULL, data->callref,
@@ -2102,12 +2102,12 @@
 	int i, rc = 0;
 
 	if (msg_type & 0x80) {
-		LOG_TRANS(trans, LOGL_DEBUG, "MSG 0x%2x not defined for PD error\n", msg_type);
+		LOG_TRANS_CAT(trans, DCC, LOGL_DEBUG, "MSG 0x%2x not defined for PD error\n", msg_type);
 		return -EINVAL;
 	}
 
 	if (!vsub) {
-		LOG_TRANS(trans, LOGL_ERROR, "Invalid conn: no subscriber\n");
+		LOG_TRANS_CAT(trans, DCC, LOGL_ERROR, "Invalid conn: no subscriber\n");
 		return -EINVAL;
 	}
 
@@ -2121,7 +2121,7 @@
 				    TRANS_CC,
 				    transaction_id, msc_cc_next_outgoing_callref());
 		if (!trans) {
-			LOG_TRANS(trans, LOGL_ERROR, "No memory for trans.\n");
+			LOG_TRANS_CAT(trans, DCC, LOGL_ERROR, "No memory for trans.\n");
 			rc = gsm48_tx_simple(msc_a,
 					     GSM48_PDISC_CC | (transaction_id << 4),
 					     GSM48_MT_CC_RELEASE_COMPL);
diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index 22e55dd..d5c2516 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -1008,7 +1008,7 @@
 	/* Allocate a new transaction */
 	struct gsm_trans *trans = trans_alloc(net, vsub, TRANS_SMS, tid, new_callref++);
 	if (!trans) {
-		LOG_TRANS(trans, LOGL_ERROR, "No memory for transaction\n");
+		LOG_TRANS_CAT(trans, DLSMS, LOGL_ERROR, "No memory for transaction\n");
 		return NULL;
 	}
 
@@ -1072,7 +1072,7 @@
 	/* Generate a new transaction ID */
 	tid = trans_assign_trans_id(net, vsub, TRANS_SMS);
 	if (tid == -1) {
-		LOG_TRANS(trans, LOGL_ERROR, "No available transaction IDs\n");
+		LOG_TRANS_CAT(trans, DLSMS, LOGL_ERROR, "No available transaction IDs\n");
 		return NULL;
 	}
 
@@ -1227,7 +1227,7 @@
 	 * A transaction we created but don't know about?
 	 */
 	if (!trans && (transaction_id & 0x8) == 0) {
-		LOG_TRANS(trans, LOGL_ERROR, "trans_id=%x allocated by us but known "
+		LOG_TRANS_CAT(trans, DLSMS, LOGL_ERROR, "trans_id=%x allocated by us but known "
 			"to us anymore. We are ignoring it, maybe a CP-ERROR "
 			"from a MS?\n",
 			transaction_id);
diff --git a/src/libmsc/gsm_09_11.c b/src/libmsc/gsm_09_11.c
index 984cc53..500da3a 100644
--- a/src/libmsc/gsm_09_11.c
+++ b/src/libmsc/gsm_09_11.c
@@ -135,8 +135,8 @@
 		 * a supplementary service.
 		 */
 		if (msg_type != GSM0480_MTYPE_REGISTER) {
-			LOG_TRANS(trans, LOGL_ERROR, "Rx wrong SS/USSD message type for new transaction: %s\n",
-				  gsm48_pdisc_msgtype_name(GSM48_PDISC_NC_SS, msg_type));
+			LOG_MSC_A(msc_a, LOGL_ERROR, "Rx wrong SS/USSD message type for new transaction: %s\n",
+			          gsm48_pdisc_msgtype_name(GSM48_PDISC_NC_SS, msg_type));
 			gsm48_tx_simple(msc_a,
 				GSM48_PDISC_NC_SS | (tid << 4),
 				GSM0480_MTYPE_RELEASE_COMPLETE);
@@ -145,7 +145,7 @@
 
 		trans = trans_alloc(net, vsub, TRANS_USSD, tid, new_callref++);
 		if (!trans) {
-			LOG_TRANS(trans, LOGL_ERROR, " -> No memory for trans\n");
+			LOG_MSC_A(msc_a, LOGL_ERROR, " -> No memory for trans\n");
 			gsm48_tx_simple(msc_a,
 				GSM48_PDISC_NC_SS | (tid << 4),
 				GSM0480_MTYPE_RELEASE_COMPLETE);
@@ -322,7 +322,7 @@
 		TRANS_ID_UNASSIGNED, gsup_msg->session_id);
 
 	if (!trans) {
-		LOG_TRANS(trans, LOGL_ERROR, " -> No memory for trans\n");
+		LOG_TRANS_CAT(trans, DMM, LOGL_ERROR, " -> No memory for trans\n");
 		return NULL;
 	}
 
diff --git a/src/libmsc/transaction.c b/src/libmsc/transaction.c
index d6f8c3b..161b180 100644
--- a/src/libmsc/transaction.c
+++ b/src/libmsc/transaction.c
@@ -131,7 +131,7 @@
 
 	/* a valid subscriber is indispensable */
 	if (vsub == NULL) {
-		LOG_TRANS(trans, LOGL_ERROR, "unable to alloc transaction, invalid subscriber (NULL)\n");
+		LOG_TRANS_CAT(trans, DMSC, LOGL_ERROR, "unable to alloc transaction, invalid subscriber (NULL)\n");
 		return NULL;
 	}
 

-- 
To view, visit https://gerrit.osmocom.org/13963
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia14bd28e1db570c487ad8e90e29a69208e2226f2
Gerrit-Change-Number: 13963
Gerrit-PatchSet: 1
Gerrit-Owner: tnt <tnt at 246tNt.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190510/ab6870a6/attachment.htm>


More information about the gerrit-log mailing list