فهرست منبع

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
Hugh Waite 11 سال پیش
والد
کامیت
c5afbe1536
1فایلهای تغییر یافته به همراه4 افزوده شده و 6 حذف شده
  1. 4 6
      modules/tm/h_table.c

+ 4 - 6
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;
 	int size;
 	char *c;
 	char *c;
 	unsigned int myrand;
 	unsigned int myrand;
 
 
-	p_msg=t->uas.request;
 	if (p_msg) {
 	if (p_msg) {
 		/* char value of a proxied transaction is
 		/* char value of a proxied transaction is
 		   calculated out of header-fields forming
 		   calculated out of header-fields forming
 		   transaction key
 		   transaction key
 		*/
 		*/
-		char_msg_val( p_msg, t->md5 );
+		char_msg_val( p_msg, hash );
 	} else {
 	} else {
 		/* char value for a UAC transaction is created
 		/* char value for a UAC transaction is created
 		   randomly -- UAC is an originating stateful element
 		   randomly -- UAC is an originating stateful element
@@ -280,7 +278,7 @@ static inline void init_synonym_id( struct cell *t )
 		*/
 		*/
 		/* HACK : not long enough */
 		/* HACK : not long enough */
 		myrand=rand();
 		myrand=rand();
-		c=t->md5;
+		c = hash;
 		size=MD5_LEN;
 		size=MD5_LEN;
 		memset(c, '0', size );
 		memset(c, '0', size );
 		int2reverse_hex( &c, &size, myrand );
 		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->relayed_reply_branch   = -1;
 	/* new_cell->T_canceled = T_UNDEFINED; */
 	/* 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_cell_lock(  new_cell );
 	init_async_lock( new_cell );
 	init_async_lock( new_cell );
 	t_stats_created();
 	t_stats_created();