[sr-dev] git:4.1: tm: Generate synonym_id based on original request

Hugh Waite hugh.waite at acision.com
Mon Jul 28 17:18:02 CEST 2014


Module: sip-router
Branch: 4.1
Commit: 19b5458e616e4dde1bb7b23cfbae0388849539ee
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=19b5458e616e4dde1bb7b23cfbae0388849539ee

Author: Hugh Waite <hugh.waite at acision.com>
Committer: Hugh Waite <hugh.waite at acision.com>
Date:   Sat Jul 26 01:18:50 2014 +0100

tm: Generate synonym_id based on original request

- Prevent allocating pkg memory in a shm-alloc'd copy
- Prevents a crash that can occur in requests with pre-3261 branch tags
(cherry picked from commit c5afbe15361bbf7e9493ad02dcabfd4c6d420109)

---

 modules/tm/h_table.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/modules/tm/h_table.c b/modules/tm/h_table.c
index db93725..3313fa0 100644
--- a/modules/tm/h_table.c
+++ b/modules/tm/h_table.c
@@ -258,20 +258,18 @@ void free_cell( struct cell* dead_cell )
 
 
 
-static inline void init_synonym_id( struct cell *t )
+static inline void init_synonym_id( struct sip_msg *p_msg, char *hash )
 {
-	struct sip_msg *p_msg;
 	int size;
 	char *c;
 	unsigned int myrand;
 
-	p_msg=t->uas.request;
 	if (p_msg) {
 		/* char value of a proxied transaction is
 		   calculated out of header-fields forming
 		   transaction key
 		*/
-		char_msg_val( p_msg, t->md5 );
+		char_msg_val( p_msg, hash );
 	} else {
 		/* char value for a UAC transaction is created
 		   randomly -- UAC is an originating stateful element
@@ -280,7 +278,7 @@ static inline void init_synonym_id( struct cell *t )
 		*/
 		/* HACK : not long enough */
 		myrand=rand();
-		c=t->md5;
+		c = hash;
 		size=MD5_LEN;
 		memset(c, '0', size );
 		int2reverse_hex( &c, &size, myrand );
@@ -387,7 +385,7 @@ struct cell*  build_cell( struct sip_msg* p_msg )
 	new_cell->relayed_reply_branch   = -1;
 	/* new_cell->T_canceled = T_UNDEFINED; */
 
-	init_synonym_id(new_cell);
+	init_synonym_id(p_msg, new_cell->md5);
 	init_cell_lock(  new_cell );
 	init_async_lock( new_cell );
 	t_stats_created();




More information about the sr-dev mailing list