Skip to content

Commit

Permalink
Fix NULL to_uri due to b2b_msg_get_to is called after accessing to_ur…
Browse files Browse the repository at this point in the history
…i in case of adv_ct is not set, so contact uri can not be parsed if advertise_contact is not provided

(cherry picked from commit 33bf277)
  • Loading branch information
truong-hua authored and rvlad-patrascu committed Mar 16, 2023
1 parent 48c051f commit b22f6a7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions modules/b2b_logic/bridging.c
Original file line number Diff line number Diff line change
Expand Up @@ -2182,6 +2182,13 @@ int b2bl_bridge_msg(struct sip_msg* msg, str* key, int entity_no, str *adv_ct)

b2b_api.apply_lumps(msg);

if (b2b_msg_get_from(msg, &from_uri, &from_dname)< 0 ||
b2b_msg_get_to(msg, &to_uri, b2bl_htable[hash_index].flags)< 0)
{
LM_ERR("Failed to get to or from from the message\n");
goto error;
}

if (!adv_ct) {
memset(&ct_uri, 0, sizeof(struct sip_uri));
if (contact_user && parse_uri(to_uri.s, to_uri.len, &ct_uri) < 0) {
Expand Down Expand Up @@ -2227,12 +2234,6 @@ int b2bl_bridge_msg(struct sip_msg* msg, str* key, int entity_no, str *adv_ct)
LM_DBG("Contact: %.*s\n", contact.len, contact.s);

/* create server entity from Invite */
if (b2b_msg_get_from(msg, &from_uri, &from_dname)< 0 ||
b2b_msg_get_to(msg, &to_uri, b2bl_htable[hash_index].flags)< 0)
{
LM_ERR("Failed to get to or from from the message\n");
goto error;
}
server_id = b2b_api.server_new(msg, adv_ct ? adv_ct : &local_contact,
b2b_server_notify, &b2bl_mod_name, tuple->key,
get_tracer(tuple), NULL, NULL);
Expand Down

0 comments on commit b22f6a7

Please sign in to comment.