Skip to content

Commit ec89b78

Browse files
committed
rr: Fix a buffer mgm bug during strict routing callbacks
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
1 parent 16ac41b commit ec89b78

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

modules/rr/loose.c

+9-7
Original file line numberDiff line numberDiff line change
@@ -574,11 +574,6 @@ static inline int after_strict(struct sip_msg* _m)
574574
}
575575
}
576576

577-
/* set the hooks for the params -bogdan
578-
* important note: RURI is already parsed by the above function, so
579-
* we just used it without any checking */
580-
ctx_rrparam_set( &_m->parsed_uri.params );
581-
582577
if (is_strict(&puri.params)) {
583578
LM_DBG("Next hop: '%.*s' is strict router\n", uri.len, ZSW(uri.s));
584579
ctx_routing_set( ROUTING_SS );
@@ -689,8 +684,15 @@ static inline int after_strict(struct sip_msg* _m)
689684

690685
}
691686

692-
/* run RR callbacks -bogdan */
693-
run_rr_callbacks( _m, ctx_rrparam_get() );
687+
/* we now have our own outbound Route set as R-URI */
688+
if (parse_sip_msg_uri(_m) < 0) {
689+
LM_ERR("failed to parse Request URI\n");
690+
return RR_ERROR;
691+
}
692+
693+
ctx_rrparam_set(&_m->parsed_uri.params);
694+
695+
run_rr_callbacks(_m, &_m->parsed_uri.params);
694696

695697
return RR_DRIVEN;
696698
}

0 commit comments

Comments
 (0)