Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update cloned msg under lock to avoid races with branch injection #3528

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions modules/tm/tm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1333,11 +1333,6 @@ static int w_t_relay( struct sip_msg *p_msg , void *flags, struct proxy_l *prox
tm_has_request_disponsition_no_cancel(p_msg)==0 )
t->flags|=T_MULTI_200OK_FLAG;

/* update the transaction only if in REQUEST route; for other types
of routes we do not want to inherit the local changes */
if (route_type==REQUEST_ROUTE)
update_cloned_msg_from_msg( t->uas.request, p_msg);

if (route_type==FAILURE_ROUTE) {
/* If called from failure route we need reset the branch counter to
* ignore the previous set of branches (already terminated) */
Expand All @@ -1347,6 +1342,12 @@ static int w_t_relay( struct sip_msg *p_msg , void *flags, struct proxy_l *prox
* created, better lock here to avoid any overlapping with
* branch injection from other processes */
LOCK_REPLIES(t);

/* update the transaction only if in REQUEST route; for other types
of routes we do not want to inherit the local changes */
if (route_type==REQUEST_ROUTE)
update_cloned_msg_from_msg( t->uas.request, p_msg);

ret = t_forward_nonack( t, p_msg, p, 1/*reset*/,1/*locked*/);
UNLOCK_REPLIES(t);
}
Expand Down