Skip to content

Commit

Permalink
tm: Fix t_on_branch() PKG memory leak
Browse files Browse the repository at this point in the history
Commit dddf9c2 introduced a regression because add_uac() is sensible
to the addresses of the (str *) address provided.

"Premature optimization is the root of all evil"...
  • Loading branch information
liviuchircu committed Jan 11, 2021
1 parent 85379e5 commit 97c6bc7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions modules/tm/t_fwd.c
Expand Up @@ -384,6 +384,9 @@ static inline unsigned int count_local_rr(struct sip_msg *req)
/* introduce a new uac to transaction; returns its branch id (>=0)
or error (<0); it doesn't send a message yet -- a reply to it
might interfere with the processes of adding multiple branches
NOTICE: do NOT provide (str *) buffers pointing to @request itself, as this
may break the function logic!
*/
static int add_uac( struct cell *t, struct sip_msg *request, const str *uri,
str* next_hop, unsigned int bflags, str* path, struct proxy_l *proxy)
Expand Down Expand Up @@ -693,9 +696,6 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
str path;
str bk_path;

/* make -Wall happy */
current_uri.s=0;

/* before doing enything, update the t flags from msg */
t->uas.request->flags = p_msg->flags;

Expand Down Expand Up @@ -757,8 +757,10 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
t->first_branch--;
}

current_uri = *GET_RURI(p_msg); /* separate storage required! */

/* as first branch, use current R-URI, bflags, etc. */
branch_ret = add_uac( t, p_msg, GET_RURI(p_msg), &backup_dst,
branch_ret = add_uac( t, p_msg, &current_uri, &backup_dst,
getb0flags(p_msg), &p_msg->path_vec, proxy);
if (branch_ret>=0)
added_branches |= 1<<branch_ret;
Expand Down

0 comments on commit 97c6bc7

Please sign in to comment.