3434
3535#define START_THINFO_BUF_SZ 1000
3636#define THINFO_MAX_BUFFER_SIZE 10000
37- #define MAX_ENCODED_SIP_URIS 12
3837
3938#define TOPOH_MATCH_TAG_MATCH 2
4039#define TOPOH_MATCH_SUCCESS 1
@@ -184,7 +183,7 @@ int topo_hiding_no_dlg(struct sip_msg *req, struct cell* t, unsigned int extra_f
184183 LM_WARN ("Cannot store DID in user when dialog support is not engaged!\n" );
185184
186185 if (!(extra_flags & TOPOH_KEEP_USER ) && params && params -> ct_callee_user .len ) {
187- param_size = sizeof * p + params -> ct_callee_user .len + sizeof ( uint16_t ) ;
186+ param_size = sizeof * p + params -> ct_callee_user .len ;
188187 } else {
189188 param_size = sizeof * p ;
190189 }
@@ -199,15 +198,11 @@ int topo_hiding_no_dlg(struct sip_msg *req, struct cell* t, unsigned int extra_f
199198
200199 if (!(extra_flags & TOPOH_KEEP_USER )) {
201200 if (params && params -> ct_callee_user .len ) {
202- p = shm_malloc (sizeof * p + params -> ct_callee_user .len );
203- if (p ) {
204- memset (p , 0 , sizeof * p );
205- p -> username .s = (char * )(p + 1 );
206- p -> username .len = params -> ct_callee_user .len ;
207- memcpy (p -> username .s , params -> ct_callee_user .s ,
208- params -> ct_callee_user .len );
209- username = & params -> ct_callee_user ;
210- }
201+ p -> username .s = (char * )(p + 1 );
202+ p -> username .len = params -> ct_callee_user .len ;
203+ memcpy (p -> username .s , params -> ct_callee_user .s ,
204+ params -> ct_callee_user .len );
205+ username = & params -> ct_callee_user ;
211206 }
212207 }
213208
@@ -477,7 +472,6 @@ static struct lump *anchor_after_last_record_route(struct sip_msg *msg) {
477472 return anchor_lump (msg , offset , HDR_RECORDROUTE_T );
478473}
479474
480- // TODO log callId perhaps?
481475static void th_no_dlg_onreply (struct cell * t , int type , struct tmcb_params * param ) {
482476 struct th_no_dlg_param * p = * (param -> param );
483477 str route_s = STR_NULL ;
@@ -680,6 +674,9 @@ static inline int th_no_dlg_onrequest(struct sip_msg *req, uint16_t flags, str *
680674 return -1 ;
681675 }
682676
677+ if (route_s .s != NULL )
678+ pkg_free (route_s .s );
679+
683680 return 1 ;
684681error :
685682 if (route_s .s != NULL ) {
@@ -793,8 +790,10 @@ static char* build_encoded_contact_suffix_legacy(struct sip_msg* msg, str rr_set
793790 }
794791 }
795792
796- if (head != NULL )
797- pkg_free (head );
793+ if (head != NULL ) {
794+ free_rr (& head );
795+ head = NULL ;
796+ }
798797
799798 total_len += params_len ;
800799
@@ -881,6 +880,8 @@ static char* build_encoded_contact_suffix_legacy(struct sip_msg* msg, str rr_set
881880 pkg_free (suffix_plain );
882881 if (rr_set_free_str )
883882 pkg_free (rr_set_free_str );
883+ if (head )
884+ free_rr (& head );
884885 return NULL ;
885886}
886887
@@ -1031,7 +1032,7 @@ static char* build_encoded_thinfo_suffix(struct sip_msg* msg, str rr_set, int *s
10311032 }
10321033
10331034 if (head != NULL ) {
1034- pkg_free ( head );
1035+ free_rr ( & head );
10351036 head = NULL ;
10361037 }
10371038
@@ -1097,15 +1098,12 @@ static char* build_encoded_thinfo_suffix(struct sip_msg* msg, str rr_set, int *s
10971098
10981099 return suffix_enc ;
10991100error :
1100- if (rr_set_free_str ) {
1101+ if (rr_set_free_str )
11011102 pkg_free (rr_set_free_str );
1102- }
1103- if (head ) {
1104- pkg_free (head );
1105- }
1106- if (suffix_enc ) {
1103+ if (head )
1104+ free_rr (& head );
1105+ if (suffix_enc )
11071106 pkg_free (suffix_enc );
1108- }
11091107 return NULL ;
11101108}
11111109
@@ -1460,17 +1458,17 @@ static decoded_info_buffer_t decode_info_buffer_legacy(str *info, const thinfo_o
14601458 for (i = 0 ; i < dec_len ; i ++ )
14611459 dec_buf_legacy [i ] ^= options -> param_password .s [i % options -> param_password .len ];
14621460
1463- #define __extract_len_and_buf (_p , _len , _s ) \
1464- do { \
1465- ( _s).len = * (short *)p; \
1466- if ((_s).len < 0 || (_s).len > _len) {\
1467- LM_ERR("bad length %d in encoded contact\n", (_s).len); \
1468- goto error;\
1469- } \
1470- (_s).s = _p + sizeof(short);\
1471- _p += sizeof(short) + (_s).len;\
1472- _len -= sizeof(short) + (_s).len;\
1473- } while(0)
1461+ #define __extract_len_and_buf (_p , _len , _s ) \
1462+ do { \
1463+ memcpy(&( _s).len, _p, sizeof (short)); \
1464+ if ((_s).len < 0 || (_s).len > _len) { \
1465+ LM_ERR("bad length %d in encoded contact\n", (_s).len); \
1466+ goto error; \
1467+ } \
1468+ (_s).s = _p + sizeof(short); \
1469+ _p += sizeof(short) + (_s).len; \
1470+ _len -= sizeof(short) + (_s).len; \
1471+ } while(0)
14741472
14751473 p = dec_buf_legacy ;
14761474 size = dec_len ;
0 commit comments