Skip to content

Commit

Permalink
[uac_registrant] fix passing wrong context to authenticated REGISTER
Browse files Browse the repository at this point in the history
When sending the authenticating REGISTER, be sure a new context is provided. This will avoid the usage of the context belonging to the first (challenged) REGISTER. This mixup of the context was breaking the tracing of these REGISTER requests via local route.

(cherry picked from commit c64766a)
  • Loading branch information
bogdan-iancu committed Jun 19, 2023
1 parent ff72f57 commit 43acad2
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions modules/uac_registrant/registrant.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ int send_register(unsigned int hash_index, reg_record_t *rec, str *auth_hdr)
{
int result, expires_len;
reg_tm_cb_t *cb_param;
context_p old_ctx;
char *p, *expires;

/* Allocate space for tm callback params */
Expand Down Expand Up @@ -811,14 +812,32 @@ int send_register(unsigned int hash_index, reg_record_t *rec, str *auth_hdr)
LM_DBG("extra_hdrs=[%p][%d]->[%.*s]\n",
extra_hdrs.s, extra_hdrs.len, extra_hdrs.len, extra_hdrs.s);

result=tmb.t_request_within(
&register_method, /* method */
&extra_hdrs, /* extra headers*/
NULL, /* body */
&rec->td, /* dialog structure*/
reg_tm_cback, /* callback function */
(void *)cb_param, /* callback param */
osips_shm_free); /* function to release the parameter */
old_ctx = current_processing_ctx;
if ( (current_processing_ctx = context_alloc(CONTEXT_GLOBAL))==NULL ) {

LM_ERR("failed to alloc new ctx in pkg\n");
result = 0;

} else {

/* reset the new to-be-used CTX */
memset( current_processing_ctx, 0, context_size(CONTEXT_GLOBAL) );

/* send the request within the new context */
result=tmb.t_request_within(
&register_method, /* method */
&extra_hdrs, /* extra headers*/
NULL, /* body */
&rec->td, /* dialog structure*/
reg_tm_cback, /* callback function */
(void *)cb_param, /* callback param */
osips_shm_free); /* function to release the parameter */

clear_global_context();

}

current_processing_ctx = old_ctx; /* restore prev context */

if (result < 1)
shm_free(cb_param);
Expand Down

0 comments on commit 43acad2

Please sign in to comment.