[sr-dev] git:master:7bf71edc: tm: relocated the crit log when branch was not set for reply transaction

Daniel-Constantin Mierla miconda at gmail.com
Thu Aug 10 10:40:50 CEST 2017


Module: kamailio
Branch: master
Commit: 7bf71edc62b26a4812b19f13f5c01f980c8e55b3
URL: https://github.com/kamailio/kamailio/commit/7bf71edc62b26a4812b19f13f5c01f980c8e55b3

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-08-10T10:39:36+02:00

tm: relocated the crit log when branch was not set for reply transaction

- added after the safety check on not accessing invalid branch indexed
  structure

---

Modified: src/modules/tm/t_reply.c

---

Diff:  https://github.com/kamailio/kamailio/commit/7bf71edc62b26a4812b19f13f5c01f980c8e55b3.diff
Patch: https://github.com/kamailio/kamailio/commit/7bf71edc62b26a4812b19f13f5c01f980c8e55b3.patch

---

diff --git a/src/modules/tm/t_reply.c b/src/modules/tm/t_reply.c
index 14939ec29b..795da9cb14 100644
--- a/src/modules/tm/t_reply.c
+++ b/src/modules/tm/t_reply.c
@@ -2180,14 +2180,18 @@ int reply_received( struct sip_msg  *p_msg )
 	branch = T_BR_UNDEFINED;
 	if (t_check(p_msg , &branch)==-1)
 		goto trans_not_found;
-	if (unlikely(branch==T_BR_UNDEFINED)) {
-		LM_CRIT("BUG: invalid branch - report to developers\n");
-		goto trans_not_found;
-	}
 	/*... if there is none, tell the core router to fwd statelessly */
 	t=get_t();
-	if ( (t==0)||(t==T_UNDEFINED))
+	if ( (t==0)||(t==T_UNDEFINED)) {
+		LM_DBG("transaction not found - (branch %d)\n", branch);
 		goto trans_not_found;
+	}
+	if (unlikely(branch==T_BR_UNDEFINED)) {
+		LM_CRIT("BUG: transaction found, but no branch matched\n");
+		/* t_check() referenced the transaction */
+		t_unref(p_msg);
+		goto trans_not_found;
+	}
 
 	/* if transaction found, increment the rpl_received counter */
 	t_stats_rpl_received();




More information about the sr-dev mailing list