Skip to content

Commit f98d082

Browse files
authored
topology_hiding: fix crash when th_callid_loop_protection is disabled (#3881)
1 parent 7ea25d9 commit f98d082

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

modules/topology_hiding/topo_hiding_logic.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,12 +1448,13 @@ static int dlg_th_decode_callid(struct sip_msg *msg)
14481448

14491449
char *th_get_encoded_callid(struct sip_msg *msg, str *tag, int *enc_len)
14501450
{
1451-
int i,j,len;
1451+
int i,j,len,append_tag;
14521452
char *new_callid;
14531453
unsigned char *old_callid;
14541454

14551455
len = msg->callid->body.len;
1456-
if (th_loop_protection && tag)
1456+
append_tag = th_loop_protection && tag;
1457+
if (append_tag)
14571458
len += tag->len + 1;
14581459

14591460
old_callid = pkg_malloc(len);
@@ -1465,7 +1466,7 @@ char *th_get_encoded_callid(struct sip_msg *msg, str *tag, int *enc_len)
14651466
memcpy(old_callid, msg->callid->body.s, msg->callid->body.len);
14661467
for (j=0;j<msg->callid->body.len;j++)
14671468
old_callid[j] = msg->callid->body.s[j] ^ topo_hiding_seed.s[j%topo_hiding_seed.len];
1468-
if (tag) {
1469+
if (append_tag) {
14691470
old_callid[msg->callid->body.len] =
14701471
TH_FROM_TAG_SEP ^ topo_hiding_seed.s[j++%topo_hiding_seed.len];
14711472
for (i = 0; i < tag->len; i++, j++)

0 commit comments

Comments
 (0)