Skip to content

Commit

Permalink
[dialog] fix missing locking in get_dlg_vals()
Browse files Browse the repository at this point in the history
Iterating the list of dlg vals must be done under lock

(cherry picked from commit 728eff0)
  • Loading branch information
bogdan-iancu committed Nov 17, 2022
1 parent 7938123 commit 166212e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/dialog/dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,8 @@ static int w_get_dlg_vals(struct sip_msg *msg, pv_spec_t *v_name,
/* dlg found - NOTE you have a ref! */
LM_DBG("dialog found, fetching all variable\n");

dlg_lock_dlg( dlg );

/* iterate the list with all the dlg variables */
for( dv=dlg->vals ; dv ; dv=dv->next) {

Expand All @@ -1461,13 +1463,15 @@ static int w_get_dlg_vals(struct sip_msg *msg, pv_spec_t *v_name,
if ( pv_set_value( msg, v_val, 0, &val)<0 ) {
LM_ERR("failed to add new value in dlg val list, ignoring\n");
/* better exit here, as we will desync the lists */
dlg_unlock_dlg( dlg );
unref_dlg(dlg, 1);
return -1;
}
}

}

dlg_unlock_dlg( dlg );
unref_dlg(dlg, 1);

return 1;
Expand Down

0 comments on commit 166212e

Please sign in to comment.