Skip to content

Commit

Permalink
tm: Fix transaction leakage with global onreply_route
Browse files Browse the repository at this point in the history
Given that the opensips.cfg execution order for replies is:
    1) onreply_route (global)
    2) reply_received(), i.e. "tm" module scope
      2.1) onreply_route (branch)
      2.2) onreply_route (transaction)

... this patch fixes some transaction leaks where if the script developer
matches the current transaction within global onreply_route, e.g. with a
random statement such as xlog("$T_reply_code\n"), it would cause an
extra ref after a transaction matching operation would be performed yet
again (??) within reply_received(), as the "tm" scope begins executing.

The fix is to simply avoid transaction lookups when evaluating tm
variables within the non-transactional, global SIP reply route.

Credits to Bogdan-Andrei Iancu for suggesting this solution
  • Loading branch information
liviuchircu committed Nov 11, 2020
1 parent fccb5bf commit 3a25c0b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions modules/tm/tm.c
Expand Up @@ -1584,8 +1584,7 @@ static int pv_get_tm_reply_code(struct sip_msg *msg, pv_param_t *param,
return -1;

/* first get the transaction */
if (t_check( msg , 0 )==-1) return -1;
if ( (t=get_t())==0) {
if (!(t = get_t()) || t == T_UNDEFINED) {
/* no T */
code = 0;
} else {
Expand Down Expand Up @@ -1632,8 +1631,7 @@ static int pv_get_tm_ruri(struct sip_msg *msg, pv_param_t *param,
return -1;

/* first get the transaction */
if (t_check( msg , 0 )==-1) return -1;
if ( (t=get_t())==0) {
if (!(t = get_t()) || t == T_UNDEFINED) {
/* no T */
if (msg!=NULL&&msg!=FAKED_REPLY && msg->first_line.type==SIP_REQUEST){
res->rs = *GET_RURI(msg);
Expand Down

0 comments on commit 3a25c0b

Please sign in to comment.