Skip to content

Commit

Permalink
rr: Fix a buffer mgm bug during strict routing callbacks
Browse files Browse the repository at this point in the history
While doing strict routing (e.g. the R-URI host is a local domain) and
executing the module callbacks, the rr module would provide some bogus
memory pointer as the result of the rr_api.get_route_param() function.

Although opensips would not crash due to the dangling pointer residing
in pkg memory, some callbacks would misbehave (e.g. uac_auth() would
fail to adjust the outbound ACK CSeq, since it cannot locate the ";aci"
Route header field parameter within the dangling pkg area).

Related to #1613
  • Loading branch information
liviuchircu committed Feb 20, 2019
1 parent 16ac41b commit ec89b78
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions modules/rr/loose.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,11 +574,6 @@ static inline int after_strict(struct sip_msg* _m)
}
}

/* set the hooks for the params -bogdan
* important note: RURI is already parsed by the above function, so
* we just used it without any checking */
ctx_rrparam_set( &_m->parsed_uri.params );

if (is_strict(&puri.params)) {
LM_DBG("Next hop: '%.*s' is strict router\n", uri.len, ZSW(uri.s));
ctx_routing_set( ROUTING_SS );
Expand Down Expand Up @@ -689,8 +684,15 @@ static inline int after_strict(struct sip_msg* _m)

}

/* run RR callbacks -bogdan */
run_rr_callbacks( _m, ctx_rrparam_get() );
/* we now have our own outbound Route set as R-URI */
if (parse_sip_msg_uri(_m) < 0) {
LM_ERR("failed to parse Request URI\n");
return RR_ERROR;
}

ctx_rrparam_set(&_m->parsed_uri.params);

run_rr_callbacks(_m, &_m->parsed_uri.params);

return RR_DRIVEN;
}
Expand Down

2 comments on commit ec89b78

@denislemire
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be backported to 2.4 branch as well? I'd love to test this fix against the nightly 2.4 packages.

@liviuchircu
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just backported it to 2.4, @denislemire . Do let me know if you run into any more issues with your strict-routing scenario.

Please sign in to comment.